File tree Expand file tree Collapse file tree 2 files changed +30
-7
lines changed
main/resources/templates/libraries/microprofile
test/java/io/quarkiverse/openapi/generator/deployment/wrapper Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -123,15 +123,13 @@ public interface {classname} {
123123 {/if}
124124 {/if}
125125 {/if}
126- {#if additionalRequestArgs}
127- {#for arg in additionalRequestArgs}
128- {arg}{#if arg_hasNext}, {/if}
129- {/for}
130- {#if is-resteasy-reactive && use-dynamic-url}, {/if}
126+ {#if additionalRequestArgs && additionalRequestArgs.length > 0}
127+ {#for arg in additionalRequestArgs}{arg}{#if arg_hasNext}, {/if}{/for}
128+ {#if (op.allParams || op.hasFormParams)}, {/if}
131129 {/if}
132130 {#if is-resteasy-reactive && use-dynamic-url}
133- // See https://quarkus.io/version/3.20/guides/rest-client#dynamic-base-urls
134- @io.quarkus.rest.client.reactive.Url String dynUrl{#if op.allParams || op.hasFormParams},{/if}
131+ // See https://quarkus.io/version/3.20/guides/rest-client#dynamic-base-urls
132+ @io.quarkus.rest.client.reactive.Url String dynUrl{#if op.allParams || op.hasFormParams},{/if}
135133 {/if}
136134 {#if op.hasFormParams}
137135 {#if is-resteasy-reactive}
Original file line number Diff line number Diff line change @@ -633,6 +633,31 @@ void verifyAdditionalRequestArgs() throws URISyntaxException {
633633 .forEach (this ::verifyApiAdditionalHTTPHeaders );
634634 }
635635
636+ @ Test
637+ void shouldGenerateAdditionalParametersWhenLengthGreaterThanZero () throws Exception {
638+ List <File > generatedFiles = createGeneratorWrapper ("petstore-openapi.json" )
639+ .withAdditionalRequestArgs ("@HeaderParam(\" X-Test\" ) String testHeader;@PathParam(\" id\" ) String id" )
640+ .generate ("org.test.additionalargs" );
641+
642+ Optional <File > file = generatedFiles .stream ()
643+ .filter (f -> f .getName ().endsWith ("PetApi.java" ))
644+ .findAny ();
645+ assertThat (file ).isNotEmpty ();
646+
647+ CompilationUnit compilationUnit = StaticJavaParser .parse (file .orElseThrow ());
648+ List <MethodDeclaration > methods = compilationUnit .findAll (MethodDeclaration .class );
649+
650+ boolean found = methods .stream ().anyMatch (m ->
651+ m .getParameters ().stream ().anyMatch (p ->
652+ p .getNameAsString ().equals ("testHeader" ) && p .getAnnotationByName ("HeaderParam" ).isPresent ()
653+ ) &&
654+ m .getParameters ().stream ().anyMatch (p ->
655+ p .getNameAsString ().equals ("id" ) && p .getAnnotationByName ("PathParam" ).isPresent ()
656+ )
657+ );
658+ assertTrue (found , "Additional parameters must be generated when additionalRequestArgs.length > 0" );
659+ }
660+
636661 @ Test
637662 void verifyCookieParams () throws URISyntaxException {
638663 List <File > generatedFiles = createGeneratorWrapper ("petstore-openapi.json" ).generate ("org.cookieParams" );
You can’t perform that action at this time.
0 commit comments