Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: error when input/openapi has cookies #681

Merged
merged 8 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class QuteTemplatingEngineAdapter extends AbstractTemplatingEngineAdapter
"enumOuterClass.qute",
"headerParams.qute",
"pathParams.qute",
"cookieParams.qute",
"pojo.qute",
"pojoQueryParam.qute",
"queryParams.qute",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,26 @@ public interface {classname} {
@jakarta.ws.rs.BeanParam {op.operationIdCamelCase}MultipartForm multipartForm{#if op.hasPathParams},{/if}{!
!}{#for p in op.pathParams}{#include pathParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasQueryParams},{/if}{!
!}{#for p in op.queryParams}{#include queryParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasBodyParams},{/if}{!
!}{#for p in op.bodyParams}{#include bodyParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasHeaderParams},{/if}{!
!}{#for p in op.bodyParams}{#include bodyParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasCookieParams},{/if}{!
!}{#for p in op.cookieParams}{#include cookieParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasHeaderParams},{/if}{!
!}{#for p in op.headerParams}{#include headerParams.qute param=p/}{#if p_hasNext}, {/if}{/for}
{#else}
@org.jboss.resteasy.annotations.providers.multipart.MultipartForm {op.operationIdCamelCase}MultipartForm multipartForm{#if op.hasPathParams},{/if}{!
!}{#for p in op.pathParams}{#include pathParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasQueryParams},{/if}{!
!}{#for p in op.queryParams}{#include queryParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasBodyParams},{/if}{!
!}{#for p in op.bodyParams}{#include bodyParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasHeaderParams},{/if}{!
!}{#for p in op.bodyParams}{#include bodyParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasCookieParams},{/if}{!
!}{#for p in op.cookieParams}{#include cookieParams.qute param=p/}{#if p_hasNext}, {/if}{/for}{#if op.hasHeaderParams},{/if}{!
!}{#for p in op.headerParams}{#include headerParams.qute param=p/}{#if p_hasNext}, {/if}{/for}
{/if}
{#else}
{#for p in op.allParams}
{#include pathParams.qute param=p/}{#include queryParams.qute param=p/}{#include bodyParams.qute param=p/}{#include headerParams.qute param=p/}{#if p_hasNext}, {/if}
{/for}
{#for p in op.allParams}{!
!}{#include pathParams.qute param=p/}{!
!}{#include queryParams.qute param=p/}{!
!}{#include bodyParams.qute param=p/}{!
!}{#include cookieParams.qute param=p/}{!
!}{#include headerParams.qute param=p/}{!
!}{#if p_hasNext}, {/if}{!
!}{/for}
{/if}
);
{#if op.hasFormParams}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{#if param.isCookieParam}{!
!}@GeneratedParam("{param.baseName}") @CookieParam("{param.baseName}") {!
!}{#if param.useBeanValidation}{#include beanValidationCore.qute p=param/}{/if}{!
!}{#if param.defaultValue}@DefaultValue("\{{param.defaultValue}\}") {/if}{!
!}{param.dataType} {param.paramName}{!
!}{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,36 @@ private void assertParameter(Optional<Parameter> optionalParameter,
});
}

@Test
void verifyCookieParams() throws URISyntaxException {
List<File> generatedFiles = createGeneratorWrapper("petstore-openapi.json")
.generate("org.cookieParams");

generatedFiles.stream()
.filter(file -> file.getPath()
.matches("PetApi.java"))
.forEach(file -> {
try {
CompilationUnit compilationUnit = StaticJavaParser.parse(file);
var positiveFounds = compilationUnit.findAll(MethodDeclaration.class)
.stream()
.filter(c -> c.getNameAsString()
.equals("findPetsByStatus"))
.filter(c -> {
assertParameter(c.getParameterByName("exampleCookie"),
"String",
Map.of("CookieParam",
"\"example-cookie\""));
return true;
})
.count();
assertThat(positiveFounds).isEqualTo(1);
} catch (FileNotFoundException e) {
throw new RuntimeException(e.getMessage());
}
});
}

@Test
void verifyAPINormalization() throws Exception {
final List<File> generatedFiles = this.createGeneratorWrapper("open-api-normalizer.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@
"sold"
]
}
},
{
"name": "example-cookie",
"in": "cookie",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
Expand Down
20 changes: 20 additions & 0 deletions docs/modules/ROOT/pages/client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ include::./includes/additional-request-args.adoc[leveloffset=+1, opts=optional]

== Known Limitations

=== Supported Arguments

Currently not all arguments are supported by this extension

*supported:*

* Body
* https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs/jakarta/ws/rs/Path.html[@PathParams]
* https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs/jakarta/ws/rs/RestQuery.html[@QueryParams]
* https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs/jakarta/ws/rs/FormParam.html[@FormParams]
* https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs/jakarta/ws/rs/CookieParam.html[@CookieParam]
* https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs/jakarta/ws/rs/HeaderParam.html[@HeaderParam]

*unsupported:*

* https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs/jakarta/ws/rs/MatrixParam.html[@MatrixParam]


(You can extend all endpoints with `additional-request-args`)

These are the known limitations of this pre-release version:

* Only Jackson support
Expand Down