Skip to content
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 @@ -123,14 +123,13 @@ public interface {classname} {
{/if}
{/if}
{/if}
{#if additionalRequestArgs}
{#for arg in additionalRequestArgs}{!
!}{arg}{#if arg_hasNext}, {/if}{/for}{!
!}{#if op.allParams || op.hasFormParams},{/if}
{#if additionalRequestArgs && additionalRequestArgs.length > 0}
{#for arg in additionalRequestArgs}{arg}{#if arg_hasNext}, {/if}{/for}
{#if (op.allParams || op.hasFormParams)}, {/if}
{/if}
{#if is-resteasy-reactive && use-dynamic-url}
// See https://quarkus.io/version/3.20/guides/rest-client#dynamic-base-urls
@io.quarkus.rest.client.reactive.Url String dynUrl{#if op.allParams || op.hasFormParams},{/if}
// See https://quarkus.io/version/3.20/guides/rest-client#dynamic-base-urls
@io.quarkus.rest.client.reactive.Url String dynUrl{#if op.allParams || op.hasFormParams},{/if}
{/if}
{#if op.hasFormParams}
{#if is-resteasy-reactive}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,28 @@ void verifyAdditionalRequestArgs() throws URISyntaxException {
.forEach(this::verifyApiAdditionalHTTPHeaders);
}

@Test
void shouldGenerateAdditionalParametersWhenLengthGreaterThanZero() throws Exception {
List<File> generatedFiles = createGeneratorWrapper("petstore-openapi.json")
.withAdditionalRequestArgs("@HeaderParam(\"X-Test\") String testHeader;@PathParam(\"id\") String id")
.generate("org.test.additionalargs");

Optional<File> file = generatedFiles.stream()
.filter(f -> f.getName().endsWith("PetApi.java"))
.findAny();
assertThat(file).isNotEmpty();

CompilationUnit compilationUnit = StaticJavaParser.parse(file.orElseThrow());
List<MethodDeclaration> methods = compilationUnit.findAll(MethodDeclaration.class);

boolean found = methods.stream()
.anyMatch(m -> m.getParameters().stream().anyMatch(
p -> p.getNameAsString().equals("testHeader") && p.getAnnotationByName("HeaderParam").isPresent()) &&
m.getParameters().stream().anyMatch(
p -> p.getNameAsString().equals("id") && p.getAnnotationByName("PathParam").isPresent()));
assertTrue(found, "Additional parameters must be generated when additionalRequestArgs.length > 0");
}

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