Skip to content

[BUG][JAVA] Deprecated endpoints are not marked with Deprecated in public webclient methods #22675

@parkito

Description

@parkito
Description

I use java 21 with Spring boot 3.5.5, openapi-generator 7.18.0

When an endpoint is marked Deprecated

paths:
  /pets:
    get:
      deprecated: true
      operationId: getPets
      summary: List all pets

Current behaviour: The public method of the generated project is not marked with @deprecated

DefaultApi defaultApi = new DefaultApi();
defaultApi.getPets() // is not marked deprecated

I expect getPets() to be deprecated because it represents the endpoint that properly marked in the specification.

More details:
The public method *getPets() uses a private method that is marked @deprecated.

   public Flux<Pet> getPets() throws WebClientResponseException {
        ParameterizedTypeReference<Pet> localVarReturnType = new ParameterizedTypeReference<Pet>() {};
        return getPetsRequestCreation().bodyToFlux(localVarReturnType);
    }
    /**
     * List all pets
     * 
     * <p><b>200</b> - A list of pets
     * @return List&lt;Pet&gt;
     * @throws WebClientResponseException if an error occurs while attempting to invoke the API
     * @deprecated
     */
    @Deprecated
    private ResponseSpec getPetsRequestCreation() throws WebClientResponseException {

Because of this, we can't use java's compilers flags to detect usage of deprecated methods

javac -Xlint:deprecation -Werror

The problem source:

api.mustache fie from webclient defines deprecation only for private methos of the API client

{{/isDeprecated}}
     */
    {{#isDeprecated}}
    @Deprecated
    {{/isDeprecated}}
    private ResponseSpec

Suggested solution:

Public methods should use deprecation mark

{{#externalDocs}}
    * {{description}}
    * @see <a href="{{url}}">{{summary}} Documentation</a>
{{/externalDocs}}
     */
    {{#isDeprecated}}
    @Deprecated
    {{/isDeprecated}}
    public {{#returnType}}{{#vendorExtensions.x-webclient-blocking}}{{#vendorExtensions.x-webclient-return-except-list-of-string}
openapi-generator version

7.18.0

OpenAPI declaration file content or url

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions