Skip to content

Commit 8a65919

Browse files
authored
fix(jaxrs-spec): generate @deprecated annotations (fixes #18941) (#23651)
* fix(jaxrs-spec): emit @deprecated for operations, params, and docs (#18941) * fix(jaxrs-spec): map OpenAPI deprecated to Java/MicroProfile -> avoid @apioperation deprecated (#18941) * feat: Run PR checklist commands
1 parent 968f998 commit 8a65919

45 files changed

Lines changed: 504 additions & 68 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
{{#responses}}
88
* @return {{{message}}}
99
{{/responses}}
10+
{{#isDeprecated}}
11+
* @deprecated
12+
{{/isDeprecated}}
1013
*/
14+
{{#isDeprecated}}
15+
@Deprecated
16+
{{/isDeprecated}}
1117
@{{httpMethod}}{{#subresourceOperation}}
1218
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
1319
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
@@ -27,7 +33,7 @@
2733
{{/implicitHeadersParams.0}}
2834
@ApiResponses(value = { {{#responses}}
2935
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
30-
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
36+
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}})
3137
@ApiResponses(value = { {{#responses}}
3238
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerV3Annotations}}
3339
{{#supportAsync}}{{>returnAsyncTypeInterface}}{{/supportAsync}}{{^supportAsync}}{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{>returnTypeInterface}}{{/returnResponse}}{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}});

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiMethod.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{{#isDeprecated}}
2+
@Deprecated
3+
{{/isDeprecated}}
14
@{{httpMethod}}{{#subresourceOperation}}
25
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
36
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
@@ -18,7 +21,7 @@
1821
@ApiResponses(value = { {{#responses}}
1922
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}}
2023
}){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
21-
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
24+
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}})
2225
@ApiResponses(value = { {{#responses}}
2326
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}}
2427
}){{/useSwaggerV3Annotations}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isBodyParam}}{{#useBeanValidation}}@Valid {{#required}}{{^isNullable}}@NotNull {{/isNullable}}{{/required}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
1+
{{#isBodyParam}}{{#isDeprecated}}@Deprecated {{/isDeprecated}}{{#useBeanValidation}}@Valid {{#required}}{{^isNullable}}@NotNull {{/isNullable}}{{/required}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isCookieParam}}@CookieParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}{{#description}} @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(description="{{.}}"){{/description}}{{/useMicroProfileOpenAPIAnnotations}} {{{dataType}}} {{paramName}}{{/isCookieParam}}
1+
{{#isCookieParam}}{{#isDeprecated}}@Deprecated {{/isDeprecated}}@CookieParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}{{#description}} @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(description="{{.}}"){{/description}}{{/useMicroProfileOpenAPIAnnotations}} {{{dataType}}} {{paramName}}{{/isCookieParam}}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumOuterClass.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ import com.fasterxml.jackson.annotation.JsonValue;
55

66
/**
77
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
8+
{{#isDeprecated}}
9+
* @deprecated
10+
{{/isDeprecated}}
811
*/
912
{{>generatedAnnotation}}
1013

11-
{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
14+
{{#isDeprecated}}
15+
@Deprecated
16+
17+
{{/isDeprecated}}{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
1218
{{#gson}}
1319
{{#allowableValues}}{{#enumVars}}
1420
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
{{#isFormParam}}{{^isFile}}@FormParam(value = "{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} @FormParam(value = "{{baseName}}") InputStream {{paramName}}InputStream{{/isFile}}{{/isFormParam}}
1+
{{#isFormParam}}
2+
{{#isDeprecated}}@Deprecated {{/isDeprecated}}{{^isFile}}@FormParam(value = "{{baseName}}") {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@FormParam(value = "{{baseName}}") InputStream {{paramName}}InputStream{{/isFile}}{{/isFormParam}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isHeaderParam}}@HeaderParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} {{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}{{#description}} @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(description="{{.}}"){{/description}}{{/useMicroProfileOpenAPIAnnotations}} {{{dataType}}} {{paramName}}{{/isHeaderParam}}
1+
{{#isHeaderParam}}{{#isDeprecated}}@Deprecated {{/isDeprecated}}@HeaderParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} {{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}{{#description}} @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(description="{{.}}"){{/description}}{{/useMicroProfileOpenAPIAnnotations}} {{{dataType}}} {{paramName}}{{/isHeaderParam}}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiInterface.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{{#isDeprecated}}
2+
/**
3+
* @deprecated
4+
*/
5+
@Deprecated
6+
{{/isDeprecated}}
17
{{#useGzipFeature}}
28
@GZIP
39
{{/useGzipFeature}}
@@ -20,15 +26,15 @@
2026
{{/implicitHeadersParams.0}}
2127
@ApiResponses(value = { {{#responses}}
2228
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
23-
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
29+
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}})
2430
@ApiResponses(value = { {{#responses}}
2531
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerV3Annotations}}{{#useMicroProfileOpenAPIAnnotations}}
2632
{{#hasAuthMethods}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirements(value = {
2733
{{#authMethods}}{{#isOAuth}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(
2834
name = "{{name}}",
2935
scopes = { {{#scopes}} "{{scope}}"{{^-last}},{{/-last}} {{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}}{{^isOAuth}} @org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(name = "{{name}}"){{^-last}},{{/-last}}{{/isOAuth}}
3036
{{/authMethods}} }){{/hasAuthMethods}}
31-
@org.eclipse.microprofile.openapi.annotations.Operation(operationId = "{{{operationId}}}", summary = "{{{summary}}}", description = "{{{notes}}}")
37+
@org.eclipse.microprofile.openapi.annotations.Operation(operationId = "{{{operationId}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}}, summary = "{{{summary}}}", description = "{{{notes}}}")
3238
{{#vendorExtensions.x-tags}}@org.eclipse.microprofile.openapi.annotations.tags.Tag(name="{{tag}}"){{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}}{{#hasProduces}}
3339
@org.eclipse.microprofile.openapi.annotations.responses.APIResponses(value = { {{#responses}}
3440
@org.eclipse.microprofile.openapi.annotations.responses.APIResponse(responseCode = "{{{code}}}", description = "{{{message}}}", {{#responseHeaders.0}}headers = { {{#responseHeaders}}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiMethod.mustache

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{{#useGzipFeature}}
22
@GZIP
33
{{/useGzipFeature}}
4+
{{#isDeprecated}}
5+
@Deprecated
6+
{{/isDeprecated}}
47
@{{httpMethod}}{{#subresourceOperation}}
58
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
69
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
@@ -21,14 +24,14 @@
2124
@ApiResponses(value = { {{#responses}}
2225
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}}
2326
}){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
24-
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}")
27+
@Operation(summary = "{{{summary}}}", description = "{{{notes}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}})
2528
@ApiResponses(value = { {{#responses}}
2629
@ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"){{^-last}},{{/-last}}{{/responses}}
2730
}){{/useSwaggerV3Annotations}}{{#useMicroProfileOpenAPIAnnotations}}
2831
{{#hasAuthMethods}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirements(value={
2932
{{#authMethods}}{{#isOAuth}}@org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(name = "{{name}}", scopes = { {{#scopes}} "{{scope}}"{{^-last}},{{/-last}} {{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}}{{^isOAuth}} @org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement(name = "{{name}}"){{^-last}},{{/-last}}{{/isOAuth}}
3033
{{/authMethods}} }){{/hasAuthMethods}}
31-
@org.eclipse.microprofile.openapi.annotations.Operation(operationId = "{{{operationId}}}", summary = "{{{summary}}}", description = "{{{notes}}}")
34+
@org.eclipse.microprofile.openapi.annotations.Operation(operationId = "{{{operationId}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}}, summary = "{{{summary}}}", description = "{{{notes}}}")
3235
{{#vendorExtensions.x-tags}}@org.eclipse.microprofile.openapi.annotations.tags.Tag(name="{{tag}}"){{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}}{{#hasProduces}}
3336
@org.eclipse.microprofile.openapi.annotations.responses.APIResponses(value = { {{#responses}}
3437
@org.eclipse.microprofile.openapi.annotations.responses.APIResponse(responseCode = "{{{code}}}", description = "{{{message}}}", {{#responseHeaders.0}}headers = { {{#responseHeaders}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isPathParam}}@PathParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}{{#description}} @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(description="{{.}}"){{/description}}{{/useMicroProfileOpenAPIAnnotations}} {{{dataType}}} {{paramName}}{{/isPathParam}}
1+
{{#isPathParam}}{{#isDeprecated}}@Deprecated {{/isDeprecated}}@PathParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}{{#description}} @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(description="{{.}}"){{/description}}{{/useMicroProfileOpenAPIAnnotations}} {{{dataType}}} {{paramName}}{{/isPathParam}}

0 commit comments

Comments
 (0)