From be25a0dec4a14f45de5830f9e6cb35d1fcb7f64f Mon Sep 17 00:00:00 2001 From: Rupert Bogensperger Date: Tue, 23 Jan 2024 15:15:12 +0100 Subject: [PATCH 1/5] added support for attional request args --- .../generator/deployment/CodegenConfig.java | 3 +- .../deployment/CommonItemConfig.java | 6 ++ .../codegen/OpenApiGeneratorCodeGenBase.java | 3 + .../OpenApiClientGeneratorWrapper.java | 7 ++ .../templates/libraries/microprofile/api.qute | 5 ++ .../OpenApiClientGeneratorWrapperTest.java | 27 +++++++ .../includes/quarkus-openapi-generator.adoc | 75 +++++++++++++++++++ 7 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java index 23d48776..825671ad 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java @@ -56,7 +56,8 @@ public enum ConfigName { GENERATE_PART_FILENAME("generate-part-filename"), PART_FILENAME_VALUE("part-filename-value"), USE_FIELD_NAME_IN_PART_FILENAME("use-field-name-in-part-filename"), - ADDITIONAL_PROPERTIES_AS_ATTRIBUTE("additional-properties-as-attribute"); + ADDITIONAL_PROPERTIES_AS_ATTRIBUTE("additional-properties-as-attribute"), + ADDITIONAL_HTTP_HEADERS("additional-http-headers"); private final String name; diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java index 1ec1e375..e35624f5 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java @@ -48,6 +48,12 @@ public class CommonItemConfig { @ConfigItem(name = "additional-api-type-annotations") public Optional additionalApiTypeAnnotations; + /** + * Add custom/additional HTTP Header to the generated client + */ + @ConfigItem(name = "additional-http-headers") + public Optional additionalHTTPHeaders; + /** * Defines if the methods should return {@link jakarta.ws.rs.core.Response} or a model. Default is false. */ diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java index ff8dcd6d..ae200691 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java @@ -205,6 +205,9 @@ protected void generate(final Config config, final Path openApiFilePath, final P getValues(config, openApiFilePath, CodegenConfig.ConfigName.ADDITIONAL_API_TYPE_ANNOTATIONS, String.class) .ifPresent(generator::withAdditionalApiTypeAnnotationsConfig); + getValues(config, openApiFilePath, CodegenConfig.ConfigName.ADDITIONAL_HTTP_HEADERS, String.class) + .ifPresent(generator::withAdditionalHTTPHeaders); + getConfigKeyValue(config, openApiFilePath) .ifPresentOrElse(generator::withConfigKey, () -> generator.withConfigKey(getSanitizedFileName(openApiFilePath))); diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java index 052bb8e1..cf5d3662 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java @@ -179,6 +179,13 @@ public OpenApiClientGeneratorWrapper withAdditionalApiTypeAnnotationsConfig(fina return this; } + public OpenApiClientGeneratorWrapper withAdditionalHTTPHeaders(final String additionalHTTPHeaders) { + if (additionalHTTPHeaders != null) { + this.configurator.addAdditionalProperty("additionalHTTPHeaders", additionalHTTPHeaders.split(";")); + } + return this; + } + public void withTemplateDir(Path templateDir) { this.configurator.addAdditionalProperty("templateDir", templateDir.toString()); } diff --git a/deployment/src/main/resources/templates/libraries/microprofile/api.qute b/deployment/src/main/resources/templates/libraries/microprofile/api.qute index 59585914..5980dd92 100644 --- a/deployment/src/main/resources/templates/libraries/microprofile/api.qute +++ b/deployment/src/main/resources/templates/libraries/microprofile/api.qute @@ -92,6 +92,11 @@ public interface {classname} { {/if} {/if} {/if} + {#if additionalHTTPHeaders} + {#for httpHeader in additionalHTTPHeaders}{! + !}{httpHeader}{#if httpHeader_hasNext}, {/if}{/for}{! + !}{#if op.hasFormParams || op.allParams},{/if} + {/if} {#if op.hasFormParams} {#if is-resteasy-reactive} @jakarta.ws.rs.BeanParam {op.operationIdCamelCase}MultipartForm multipartForm{#if op.hasPathParams},{/if}{! diff --git a/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java b/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java index 9e523d5c..0d903ab8 100644 --- a/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java +++ b/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java @@ -536,6 +536,33 @@ private void verifyApiAdditionalAnnotations(File file) { } } + @Test + void verifyAdditionalHTTPHeaders() throws URISyntaxException { + List generatedFiles = createGeneratorWrapper("petstore-openapi.json") + .withEnabledSecurityGeneration(false) + .withAdditionalHTTPHeaders( + "@HeaderParam(\"jaxrs-style-header\") String headerValue, @HeaderParam(\"x-correlation-id\") String correlationId") + .generate("org.additionalHTTPHeaders"); + assertFalse(generatedFiles.isEmpty()); + + generatedFiles.stream() + .filter(file -> file.getPath().matches(".*api.*Api.java")) + .forEach(this::verifyApiAdditionalHTTPHeaders); + } + + private void verifyApiAdditionalHTTPHeaders(File file) { + try { + CompilationUnit compilationUnit = StaticJavaParser.parse(file); + compilationUnit.findAll(ClassOrInterfaceDeclaration.class) + .forEach(c -> { + assertThat(c.getAnnotationByName("Foo")).isPresent(); + assertThat(c.getAnnotationByName("Bar")).isPresent(); + }); + } catch (FileNotFoundException e) { + throw new RuntimeException(e.getMessage()); + } + } + @Test void verifyAPINormalization() throws Exception { final List generatedFiles = this.createGeneratorWrapper("open-api-normalizer.json") diff --git a/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc b/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc new file mode 100644 index 00000000..3f69fdfa --- /dev/null +++ b/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc @@ -0,0 +1,75 @@ + +:summaryTableId: quarkus-openapi-generator +[.configuration-legend] +icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime +[.configuration-reference.searchable, cols="80,.^10,.^10"] +|=== + +h|[[quarkus-openapi-generator_configuration]]link:#quarkus-openapi-generator_configuration[Configuration property] + +h|Type +h|Default + +a| [[quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.token-propagation]]`link:#quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.token-propagation[quarkus.openapi-generator."item-configs".auth."auth-configs".token-propagation]` + + +[.description] +-- +Enables the authentication token propagation for this particular securityScheme. + +For example, given a file named petstore.json with a securityScheme named "petstore-auth" the following configuration must be used. + +quarkus.openapi-generator.petstore_json.auth.petstore_auth.token-propagation=true + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__TOKEN_PROPAGATION+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__TOKEN_PROPAGATION+++` +endif::add-copy-button-to-env-var[] +--|boolean +|`false` + + +a| [[quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.header-name]]`link:#quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.header-name[quarkus.openapi-generator."item-configs".auth."auth-configs".header-name]` + + +[.description] +-- +Configures a particular http header attribute from were to take the security token from when the token propagation is enabled. Use this fine-grained configuration in very particular scenarios. + +For example, given a file named petstore.json with a securityScheme named "petstore-auth" the following configuration must be used. + +quarkus.openapi-generator.petstore_json.auth.petstore_auth.header-name=MyParticularHttpHeaderName + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__HEADER_NAME+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__HEADER_NAME+++` +endif::add-copy-button-to-env-var[] +--|string +| + + +a| [[quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-auth-config-params]]`link:#quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-auth-config-params[quarkus.openapi-generator."item-configs".auth."auth-configs"]` + + +[.description] +-- +Configures a particular parameter value to be used by any of the different internal authentication filters that processes the different securityScheme definitions. + +For example, given a file named petstore.json with a securityScheme named "petstore-basic-auth", that is of http basic authentication type, the following configuration can establish the user and password to be used. must be used. + +quarkus.openapi-generator.petstore_json.auth.petstore_basic_auth.username=MyUserName quarkus.openapi-generator.petstore_json.auth.petstore_basic_auth.password=MyPassword + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS_+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS_+++` +endif::add-copy-button-to-env-var[] +--|`Map` +| + +|=== \ No newline at end of file From 5dbcd957f13a8539500973ec8a135c349e2d43df Mon Sep 17 00:00:00 2001 From: Rupert Bogensperger Date: Tue, 23 Jan 2024 15:17:19 +0100 Subject: [PATCH 2/5] added support for attional request args --- .../generator/deployment/CodegenConfig.java | 2 +- .../deployment/CommonItemConfig.java | 4 +- .../codegen/OpenApiGeneratorCodeGenBase.java | 4 +- .../OpenApiClientGeneratorWrapper.java | 6 +-- .../templates/libraries/microprofile/api.qute | 6 +-- .../OpenApiClientGeneratorWrapperTest.java | 41 +++++++++++++++---- 6 files changed, 45 insertions(+), 18 deletions(-) diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java index 825671ad..2f22b1e2 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CodegenConfig.java @@ -57,7 +57,7 @@ public enum ConfigName { PART_FILENAME_VALUE("part-filename-value"), USE_FIELD_NAME_IN_PART_FILENAME("use-field-name-in-part-filename"), ADDITIONAL_PROPERTIES_AS_ATTRIBUTE("additional-properties-as-attribute"), - ADDITIONAL_HTTP_HEADERS("additional-http-headers"); + ADDITIONAL_REQUEST_ARGS("additional-request-args"); private final String name; diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java index e35624f5..4c818170 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java @@ -51,8 +51,8 @@ public class CommonItemConfig { /** * Add custom/additional HTTP Header to the generated client */ - @ConfigItem(name = "additional-http-headers") - public Optional additionalHTTPHeaders; + @ConfigItem(name = "additional-request-args") + public Optional additionalRequestArgs; /** * Defines if the methods should return {@link jakarta.ws.rs.core.Response} or a model. Default is false. diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java index ae200691..62c754c7 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java @@ -205,8 +205,8 @@ protected void generate(final Config config, final Path openApiFilePath, final P getValues(config, openApiFilePath, CodegenConfig.ConfigName.ADDITIONAL_API_TYPE_ANNOTATIONS, String.class) .ifPresent(generator::withAdditionalApiTypeAnnotationsConfig); - getValues(config, openApiFilePath, CodegenConfig.ConfigName.ADDITIONAL_HTTP_HEADERS, String.class) - .ifPresent(generator::withAdditionalHTTPHeaders); + getValues(config, openApiFilePath, CodegenConfig.ConfigName.ADDITIONAL_REQUEST_ARGS, String.class) + .ifPresent(generator::withAdditionalRequestArgs); getConfigKeyValue(config, openApiFilePath) .ifPresentOrElse(generator::withConfigKey, diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java index cf5d3662..bc116e37 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java @@ -179,9 +179,9 @@ public OpenApiClientGeneratorWrapper withAdditionalApiTypeAnnotationsConfig(fina return this; } - public OpenApiClientGeneratorWrapper withAdditionalHTTPHeaders(final String additionalHTTPHeaders) { - if (additionalHTTPHeaders != null) { - this.configurator.addAdditionalProperty("additionalHTTPHeaders", additionalHTTPHeaders.split(";")); + public OpenApiClientGeneratorWrapper withAdditionalRequestArgs(final String additionalRequestArgs) { + if (additionalRequestArgs != null) { + this.configurator.addAdditionalProperty("additionalRequestArgs", additionalRequestArgs.split(";")); } return this; } diff --git a/deployment/src/main/resources/templates/libraries/microprofile/api.qute b/deployment/src/main/resources/templates/libraries/microprofile/api.qute index 5980dd92..0f9e7758 100644 --- a/deployment/src/main/resources/templates/libraries/microprofile/api.qute +++ b/deployment/src/main/resources/templates/libraries/microprofile/api.qute @@ -92,9 +92,9 @@ public interface {classname} { {/if} {/if} {/if} - {#if additionalHTTPHeaders} - {#for httpHeader in additionalHTTPHeaders}{! - !}{httpHeader}{#if httpHeader_hasNext}, {/if}{/for}{! + {#if additionalRequestArgs} + {#for arg in additionalRequestArgs}{! + !}{arg}{#if arg_hasNext}, {/if}{/for}{! !}{#if op.hasFormParams || op.allParams},{/if} {/if} {#if op.hasFormParams} diff --git a/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java b/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java index 0d903ab8..b2d47462 100644 --- a/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java +++ b/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java @@ -537,32 +537,59 @@ private void verifyApiAdditionalAnnotations(File file) { } @Test - void verifyAdditionalHTTPHeaders() throws URISyntaxException { + void verifyAdditionalRequestArgs() throws URISyntaxException { List generatedFiles = createGeneratorWrapper("petstore-openapi.json") .withEnabledSecurityGeneration(false) - .withAdditionalHTTPHeaders( - "@HeaderParam(\"jaxrs-style-header\") String headerValue, @HeaderParam(\"x-correlation-id\") String correlationId") + .withAdditionalRequestArgs( + "@HeaderParam(\"jaxrs-style-header\") String headerValue;@HeaderParam(\"x-correlation-id\") String correlationId;@PathParam(\"stream\") String stream") .generate("org.additionalHTTPHeaders"); assertFalse(generatedFiles.isEmpty()); generatedFiles.stream() - .filter(file -> file.getPath().matches(".*api.*Api.java")) + .filter(file -> file.getPath() + .matches(".*api.*Api.java")) .forEach(this::verifyApiAdditionalHTTPHeaders); } private void verifyApiAdditionalHTTPHeaders(File file) { try { CompilationUnit compilationUnit = StaticJavaParser.parse(file); - compilationUnit.findAll(ClassOrInterfaceDeclaration.class) + compilationUnit.findAll(MethodDeclaration.class) .forEach(c -> { - assertThat(c.getAnnotationByName("Foo")).isPresent(); - assertThat(c.getAnnotationByName("Bar")).isPresent(); + assertParameter(c.getParameterByName("correlationId"), + "String", + Map.of("HeaderParam", + "\"x-correlation-id\"")); + assertParameter(c.getParameterByName("headerValue"), + "String", + Map.of("HeaderParam", + "\"jaxrs-style-header\"")); + assertParameter(c.getParameterByName("stream"), + "String", + Map.of("PathParam", + "\"stream\"")); }); } catch (FileNotFoundException e) { throw new RuntimeException(e.getMessage()); } } + private void assertParameter(Optional optionalParameter, + String type, + Map annotations) { + assertThat(optionalParameter).isPresent(); + var parameter = optionalParameter.orElseThrow(); + assertThat(parameter.getTypeAsString()).isEqualTo(type); + annotations.forEach((annotationName, annotationValue) -> { + var parameterAnnotation = parameter.getAnnotationByName(annotationName); + assertThat(parameterAnnotation).isPresent(); + assertThat(parameterAnnotation.get() + .asSingleMemberAnnotationExpr() + .getMemberValue() + .toString()).hasToString(annotationValue); + }); + } + @Test void verifyAPINormalization() throws Exception { final List generatedFiles = this.createGeneratorWrapper("open-api-normalizer.json") From c51f4fdb5efc75ff30e0979c89fa4e627f9c2f4a Mon Sep 17 00:00:00 2001 From: Rupert Bogensperger Date: Tue, 23 Jan 2024 15:25:55 +0100 Subject: [PATCH 3/5] cleanup --- .../deployment/CommonItemConfig.java | 2 +- .../includes/quarkus-openapi-generator.adoc | 75 ------------------- 2 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java index 4c818170..a16fce6a 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java @@ -49,7 +49,7 @@ public class CommonItemConfig { public Optional additionalApiTypeAnnotations; /** - * Add custom/additional HTTP Header to the generated client + * Add custom/additional HTTP Headers or other args to every request */ @ConfigItem(name = "additional-request-args") public Optional additionalRequestArgs; diff --git a/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc b/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc deleted file mode 100644 index 3f69fdfa..00000000 --- a/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc +++ /dev/null @@ -1,75 +0,0 @@ - -:summaryTableId: quarkus-openapi-generator -[.configuration-legend] -icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime -[.configuration-reference.searchable, cols="80,.^10,.^10"] -|=== - -h|[[quarkus-openapi-generator_configuration]]link:#quarkus-openapi-generator_configuration[Configuration property] - -h|Type -h|Default - -a| [[quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.token-propagation]]`link:#quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.token-propagation[quarkus.openapi-generator."item-configs".auth."auth-configs".token-propagation]` - - -[.description] --- -Enables the authentication token propagation for this particular securityScheme. - -For example, given a file named petstore.json with a securityScheme named "petstore-auth" the following configuration must be used. - -quarkus.openapi-generator.petstore_json.auth.petstore_auth.token-propagation=true - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__TOKEN_PROPAGATION+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__TOKEN_PROPAGATION+++` -endif::add-copy-button-to-env-var[] ---|boolean -|`false` - - -a| [[quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.header-name]]`link:#quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-.header-name[quarkus.openapi-generator."item-configs".auth."auth-configs".header-name]` - - -[.description] --- -Configures a particular http header attribute from were to take the security token from when the token propagation is enabled. Use this fine-grained configuration in very particular scenarios. - -For example, given a file named petstore.json with a securityScheme named "petstore-auth" the following configuration must be used. - -quarkus.openapi-generator.petstore_json.auth.petstore_auth.header-name=MyParticularHttpHeaderName - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__HEADER_NAME+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS__HEADER_NAME+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a| [[quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-auth-config-params]]`link:#quarkus-openapi-generator_quarkus.openapi-generator.-item-configs-.auth.-auth-configs-auth-config-params[quarkus.openapi-generator."item-configs".auth."auth-configs"]` - - -[.description] --- -Configures a particular parameter value to be used by any of the different internal authentication filters that processes the different securityScheme definitions. - -For example, given a file named petstore.json with a securityScheme named "petstore-basic-auth", that is of http basic authentication type, the following configuration can establish the user and password to be used. must be used. - -quarkus.openapi-generator.petstore_json.auth.petstore_basic_auth.username=MyUserName quarkus.openapi-generator.petstore_json.auth.petstore_basic_auth.password=MyPassword - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS_+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_OPENAPI_GENERATOR__ITEM_CONFIGS__AUTH__AUTH_CONFIGS_+++` -endif::add-copy-button-to-env-var[] ---|`Map` -| - -|=== \ No newline at end of file From e5f868f832f207903d4594c23ff0358498f5807c Mon Sep 17 00:00:00 2001 From: Rupert Bogensperger Date: Tue, 23 Jan 2024 16:26:32 +0100 Subject: [PATCH 4/5] added documentation --- .../pages/includes/additional-request-args.adoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docs/modules/ROOT/pages/includes/additional-request-args.adoc diff --git a/docs/modules/ROOT/pages/includes/additional-request-args.adoc b/docs/modules/ROOT/pages/includes/additional-request-args.adoc new file mode 100644 index 00000000..5fc9f88b --- /dev/null +++ b/docs/modules/ROOT/pages/includes/additional-request-args.adoc @@ -0,0 +1,17 @@ +To add custom request specific parameters you can use the `additional-request-args` property. + +Should work with: + +* @PathParam +* @QueryParam +* @CookieParam +* @FormParam +* @MatrixParam + +To use `additional-request-args` as attribute, add the following entry to your properties file. In this example, our spec file is in `src/main/openapi/petstore.json`: + +---- +quarkus.openapi-generator.codegen.spec.petstore_json.additional-request-args=@CookieParam("cookie") String cookie;@HeaderParam("x-correlation-id") String correlationId +---- + +This configuration is applied to every generated method. \ No newline at end of file From 9698ddf72f35590287e17eeb597eca49a9d4a8b2 Mon Sep 17 00:00:00 2001 From: Rupert Bogensperger Date: Sun, 28 Jan 2024 07:04:08 +0100 Subject: [PATCH 5/5] added entry in index --- docs/modules/ROOT/pages/index.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index eaad1d84..d99648ff 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -163,6 +163,12 @@ include::./includes/template-customization.adoc[leveloffset=+1, opts=optional] include::./includes/additional-properties-as-attribute.adoc[leveloffset=+1, opts=optional] +[[additional-request-args]] +== Add Additional Request Arguments to each API Method + +include::./includes/additional-request-args.adoc[leveloffset=+1, opts=optional] + + == Known Limitations These are the known limitations of this pre-release version: