From 0ea24ffa3fc89133afae170b784908c7aaac624d Mon Sep 17 00:00:00 2001 From: flabbamann Date: Tue, 21 Jul 2026 15:25:46 +0200 Subject: [PATCH] [java][restclient] move @Deprecated annotation to public methods --- .../Java/libraries/restclient/api.mustache | 24 ++++++++++++++----- .../org/openapitools/client/api/PetApi.java | 8 +++++-- .../org/openapitools/client/api/PetApi.java | 8 +++++-- .../org/openapitools/client/api/PetApi.java | 8 +++++-- .../org/openapitools/client/api/PetApi.java | 8 +++++-- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache index a56461f5f0a2..66dd26b4fd60 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache @@ -76,13 +76,7 @@ public class {{classname}} { * {{description}} * @see {{summary}} Documentation {{/externalDocs}} -{{#isDeprecated}} - * @deprecated -{{/isDeprecated}} */ - {{#isDeprecated}} - @Deprecated - {{/isDeprecated}} private ResponseSpec {{operationId}}RequestCreation({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{>nullableArgument}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{>nullableArgument}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException { Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}} @@ -179,7 +173,13 @@ public class {{classname}} { * {{description}} * @see {{summary}} Documentation {{/externalDocs}} +{{#isDeprecated}} + * @deprecated +{{/isDeprecated}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{>nullableArgument}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{>nullable_var_annotations}} {{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException { {{#returnType}}ParameterizedTypeReference<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}} {{#returnType}}return {{/returnType}}{{operationId}}RequestCreation({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).body(localVarReturnType); @@ -196,7 +196,13 @@ public class {{classname}} { * {{description}} * @see {{summary}} Documentation {{/externalDocs}} +{{#isDeprecated}} + * @deprecated +{{/isDeprecated}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}ResponseEntity<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}ResponseEntity{{/returnType}} {{operationId}}WithHttpInfo({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{>nullableArgument}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{>nullable_var_annotations}} {{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException { {{#returnType}}ParameterizedTypeReference<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}} return {{operationId}}RequestCreation({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).toEntity(localVarReturnType); @@ -214,7 +220,13 @@ public class {{classname}} { * {{description}} * @see {{summary}} Documentation {{/externalDocs}} +{{#isDeprecated}} + * @deprecated +{{/isDeprecated}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public ResponseSpec {{operationId}}WithResponseSpec({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{>nullableArgument}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{>nullableArgument}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException { return {{operationId}}RequestCreation({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); } diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/api/PetApi.java index ed6ecafa6072..711986157260 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/api/PetApi.java @@ -288,9 +288,7 @@ public ResponseSpec findPetsByStatusWithResponseSpec(@jakarta.annotation.Nonnull * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API - * @deprecated */ - @Deprecated private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { Object postBody = null; // verify the required parameter 'tags' is set @@ -328,7 +326,9 @@ private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull S * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).body(localVarReturnType); @@ -342,7 +342,9 @@ public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) thr * @param tags Tags to filter by * @return ResponseEntity<Set<Pet>> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).toEntity(localVarReturnType); @@ -356,7 +358,9 @@ public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.N * @param tags Tags to filter by * @return ResponseSpec * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseSpec findPetsByTagsWithResponseSpec(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { return findPetsByTagsRequestCreation(tags); } diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/api/PetApi.java index 6095abfa4697..3d50079a4a00 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/api/PetApi.java @@ -371,9 +371,7 @@ public ResponseSpec findPetsByStatusWithResponseSpec(@jakarta.annotation.Nonnull * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API - * @deprecated */ - @Deprecated private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { Object postBody = null; // verify the required parameter 'tags' is set @@ -411,7 +409,9 @@ private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull S * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).body(localVarReturnType); @@ -425,7 +425,9 @@ public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) thr * @param tags Tags to filter by * @return ResponseEntity<Set<Pet>> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).toEntity(localVarReturnType); @@ -439,7 +441,9 @@ public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.N * @param tags Tags to filter by * @return ResponseSpec * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseSpec findPetsByTagsWithResponseSpec(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { return findPetsByTagsRequestCreation(tags); } diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java index b7402ce1011a..dd7dd26d51f2 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java @@ -327,9 +327,7 @@ public ResponseSpec findPetsByStatusWithResponseSpec(@jakarta.annotation.Nonnull * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API - * @deprecated */ - @Deprecated private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { Object postBody = null; // verify the required parameter 'tags' is set @@ -367,7 +365,9 @@ private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull S * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).body(localVarReturnType); @@ -381,7 +381,9 @@ public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) thr * @param tags Tags to filter by * @return ResponseEntity<Set<Pet>> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).toEntity(localVarReturnType); @@ -395,7 +397,9 @@ public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.N * @param tags Tags to filter by * @return ResponseSpec * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseSpec findPetsByTagsWithResponseSpec(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { return findPetsByTagsRequestCreation(tags); } diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/api/PetApi.java index ed6ecafa6072..711986157260 100644 --- a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/api/PetApi.java @@ -288,9 +288,7 @@ public ResponseSpec findPetsByStatusWithResponseSpec(@jakarta.annotation.Nonnull * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API - * @deprecated */ - @Deprecated private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { Object postBody = null; // verify the required parameter 'tags' is set @@ -328,7 +326,9 @@ private ResponseSpec findPetsByTagsRequestCreation(@jakarta.annotation.Nonnull S * @param tags Tags to filter by * @return Set<Pet> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).body(localVarReturnType); @@ -342,7 +342,9 @@ public Set findPetsByTags(@jakarta.annotation.Nonnull Set tags) thr * @param tags Tags to filter by * @return ResponseEntity<Set<Pet>> * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference<>() {}; return findPetsByTagsRequestCreation(tags).toEntity(localVarReturnType); @@ -356,7 +358,9 @@ public ResponseEntity> findPetsByTagsWithHttpInfo(@jakarta.annotation.N * @param tags Tags to filter by * @return ResponseSpec * @throws RestClientResponseException if an error occurs while attempting to invoke the API + * @deprecated */ + @Deprecated public ResponseSpec findPetsByTagsWithResponseSpec(@jakarta.annotation.Nonnull Set tags) throws RestClientResponseException { return findPetsByTagsRequestCreation(tags); }