diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md index 12bc9a24ae90..5407b0b894ef 100644 --- a/docs/generators/groovy.md +++ b/docs/generators/groovy.md @@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md index 58520d7461c8..e77c38151eb3 100644 --- a/docs/generators/java-camel.md +++ b/docs/generators/java-camel.md @@ -120,7 +120,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null |x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null |x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false |x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md index 7f60cf91dbde..a274c0e0307f 100644 --- a/docs/generators/java-helidon-client.md +++ b/docs/generators/java-helidon-client.md @@ -77,7 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null |x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono/Flux` or `return T/List/Set` & execute `.block()` inside generated method)|OPERATION|false diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md index 2035bb8c6fbd..a34d62118c13 100644 --- a/docs/generators/java-helidon-server.md +++ b/docs/generators/java-helidon-server.md @@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md index c97cc488b150..8b8b35ea29dc 100644 --- a/docs/generators/java-inflector.md +++ b/docs/generators/java-inflector.md @@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md index f8c968280ec4..1d3c4c201bd7 100644 --- a/docs/generators/java-micronaut-client.md +++ b/docs/generators/java-micronaut-client.md @@ -103,7 +103,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md index 9cb2ad4dbbcb..a848e57254ac 100644 --- a/docs/generators/java-micronaut-server.md +++ b/docs/generators/java-micronaut-server.md @@ -102,7 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-microprofile.md b/docs/generators/java-microprofile.md index 7eb9758f9f59..1a6d6369a0a6 100644 --- a/docs/generators/java-microprofile.md +++ b/docs/generators/java-microprofile.md @@ -114,7 +114,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null |x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono/Flux` or `return T/List/Set` & execute `.block()` inside generated method)|OPERATION|false diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md index 52455c5fea16..d321b030be83 100644 --- a/docs/generators/java-msf4j.md +++ b/docs/generators/java-msf4j.md @@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md index 6ecb576ac901..4a96c9d89d9b 100644 --- a/docs/generators/java-pkmst.md +++ b/docs/generators/java-pkmst.md @@ -89,7 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md index bfdef88970f0..1e4efaaeae5b 100644 --- a/docs/generators/java-play-framework.md +++ b/docs/generators/java-play-framework.md @@ -92,7 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md index 202f013209d0..ca484ad146ed 100644 --- a/docs/generators/java-undertow-server.md +++ b/docs/generators/java-undertow-server.md @@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md index 3144df23e1a1..8c98816db81c 100644 --- a/docs/generators/java-vertx-web.md +++ b/docs/generators/java-vertx-web.md @@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md index 4592996516e1..9720c15d8bdb 100644 --- a/docs/generators/java-vertx.md +++ b/docs/generators/java-vertx.md @@ -85,7 +85,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java-wiremock.md b/docs/generators/java-wiremock.md index 081a1296745e..09fb082309e2 100644 --- a/docs/generators/java-wiremock.md +++ b/docs/generators/java-wiremock.md @@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/java.md b/docs/generators/java.md index c8b395bb02ed..816f4f2228a6 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -114,7 +114,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null |x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono/Flux` or `return T/List/Set` & execute `.block()` inside generated method)|OPERATION|false diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md index f990de40ddb6..d911fd30b0f3 100644 --- a/docs/generators/jaxrs-cxf-cdi.md +++ b/docs/generators/jaxrs-cxf-cdi.md @@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index 68d153daf209..04ae1cfee4e1 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -87,7 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index f72c477c3b73..8c34c65d1460 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -110,7 +110,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index 89caf27c7ad3..12deda54824d 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -105,7 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md index d3b30f001e46..0965570fdde4 100644 --- a/docs/generators/jaxrs-jersey.md +++ b/docs/generators/jaxrs-jersey.md @@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md index 8645361f8435..6973aecf1dba 100644 --- a/docs/generators/jaxrs-resteasy-eap.md +++ b/docs/generators/jaxrs-resteasy-eap.md @@ -89,7 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md index af6e8c0aa2dd..f48428ba1c92 100644 --- a/docs/generators/jaxrs-resteasy.md +++ b/docs/generators/jaxrs-resteasy.md @@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md index f1ff6d31bb66..6f9fb5a40620 100644 --- a/docs/generators/jaxrs-spec.md +++ b/docs/generators/jaxrs-spec.md @@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null ## IMPORT MAPPING diff --git a/docs/generators/spring.md b/docs/generators/spring.md index d026204231ae..b71cefb3c126 100644 --- a/docs/generators/spring.md +++ b/docs/generators/spring.md @@ -113,7 +113,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null |x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null |x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null -|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null +|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null |x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null |x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false |x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java index c9b285475eca..61cee17f86fe 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java @@ -19,7 +19,7 @@ X_ACCEPTS("x-accepts", ExtensionLevel.OPERATION, "Specify custom value for 'Accept' header for operation", null), X_CONTENT_TYPE("x-content-type", ExtensionLevel.OPERATION, "Specify custom value for 'Content-Type' header for operation", null), X_CLASS_EXTRA_ANNOTATION("x-class-extra-annotation", ExtensionLevel.MODEL, "List of custom annotations to be added to model", null), - X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", ExtensionLevel.FIELD, "List of custom annotations to be added to property", null), + X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", Arrays.asList(ExtensionLevel.FIELD, ExtensionLevel.OPERATION_PARAMETER), "List of custom annotations to be added to property", null), X_OPERATION_EXTRA_ANNOTATION("x-operation-extra-annotation", ExtensionLevel.OPERATION, "List of custom annotations to be added to operation", null), X_VERSION_PARAM("x-version-param", ExtensionLevel.OPERATION_PARAMETER, "Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false", null), X_PATTERN_MESSAGE("x-pattern-message", Arrays.asList(ExtensionLevel.FIELD, ExtensionLevel.OPERATION_PARAMETER), "Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable", null), diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache index b9589c14778c..a9b35fe854b6 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache @@ -1 +1 @@ -{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file +{{#isHeaderParam}}{{#vendorExtensions.x-field-extra-annotation}}{{{vendorExtensions.x-field-extra-annotation}}} {{/vendorExtensions.x-field-extra-annotation}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache index a0ce56314d1a..a5f2e6e454b3 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache @@ -1 +1 @@ -{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{>paramDoc}} @PathVariable("{{baseName}}"){{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file +{{#isPathParam}}{{#vendorExtensions.x-field-extra-annotation}}{{{vendorExtensions.x-field-extra-annotation}}} {{/vendorExtensions.x-field-extra-annotation}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{>paramDoc}} @PathVariable("{{baseName}}"){{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache index 1b7fac3512e6..b8226381ee13 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache @@ -1 +1 @@ -{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/isModel}}{{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file +{{#isQueryParam}}{{#vendorExtensions.x-field-extra-annotation}}{{{vendorExtensions.x-field-extra-annotation}}} {{/vendorExtensions.x-field-extra-annotation}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/isModel}}{{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index a32101a09cd0..1a4c07ef12e8 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -3269,6 +3269,52 @@ public void testEnumCaseSensitive_issue8084() throws IOException { .bodyContainsLines("if (b.value.equals(value)) {"); } + @Test + public void testHasOperationParameterExtraAnnotation_issue18224() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_18224.yaml"); + final SpringCodegen codegen = new SpringCodegen(); + codegen.setOpenAPI(openAPI); + codegen.setOutputDir(output.getAbsolutePath()); + + codegen.additionalProperties().put(SpringCodegen.DATE_LIBRARY, "java8-localdatetime"); + codegen.additionalProperties().put(INTERFACE_ONLY, "true"); + codegen.additionalProperties().put(USE_RESPONSE_ENTITY, "false"); + codegen.additionalProperties().put(DELEGATE_PATTERN, "true"); + codegen.additionalProperties().put(REQUEST_MAPPING_OPTION, "api_interface"); + codegen.additionalProperties().put(SPRING_CONTROLLER, "true"); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + generator.setGenerateMetadata(false); // skip metadata generation + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + + Map files = generator.opts(input).generate().stream() + .collect(Collectors.toMap(File::getName, Function.identity())); + + JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(files.get("TestApi.java")); + javaFileAssert + .assertMethod("_postToTest") + .assertParameter("groupObj") + .assertParameterAnnotations() + .containsWithName("com.test.MyAnnotationInPath") + .toParameter() + .toMethod() + .assertParameter("token") + .assertParameterAnnotations() + .containsWithName("com.test.MyAnnotationInQuery") + .toParameter() + .toMethod() + .assertParameter("clientId") + .assertParameterAnnotations() + .containsWithName("com.test.MyAnnotationInHeader"); + } + @Test public void testHasOperationExtraAnnotation_issue15822() throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_18224.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_18224.yaml new file mode 100644 index 000000000000..9dd78620e0b1 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/issue_18224.yaml @@ -0,0 +1,66 @@ +openapi: 3.0.3 +info: + title: sample spec + version: 1.0.0 +paths: + /test/{groupObj}: + post: + summary: Post to test + description: '' + operationId: postToTest + parameters: + - $ref: '#/components/parameters/groupObj' + - $ref: '#/components/parameters/token' + - $ref: '#/components/parameters/clientId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ObjTest' + responses: + 201: + description: success +components: + parameters: + groupObj: + in: path + name: groupObj + required: true + schema: + type: string + pattern: "[a-zA-Z]" + x-pattern-message: "Only letters" + x-field-extra-annotation: '@com.test.MyAnnotationInPath' + token: + in: query + name: token + required: true + schema: + type: string + pattern: "[0-9a-fA-F]" + x-pattern-message: "Only numbers and letters a-f" + x-field-extra-annotation: '@com.test.MyAnnotationInQuery' + clientId: + in: header + name: clientId + required: true + schema: + type: string + pattern: "\\d" + x-pattern-message: "Only numbers" + x-field-extra-annotation: '@com.test.MyAnnotationInHeader' + schemas: + ObjTest: + description: A model to return + type: object + properties: + field1: + type: integer + format: int64 + field2: + type: string + pattern: "\\w" + x-pattern-message: "Only letters, numbers and underscore" + field3: + type: string + pattern: "\\w"