Skip to content

[JAVA] 3.0.65 java stub generates method with no return value for get endpoints if $ref is used #12504

Open
@leberknecht

Description

Description

With 3.0.65 the methods that are generated for get endpoints (havent checked others) are not returning anything. Same specs worked with 3.0.64.

The generated code looks like this:

    public void whateverGet() throws ApiException {
        whateverGetWithHttpInfo();
    }

while with 3.0.64:

    public InlineResponse200 whateverGet() throws ApiException {
        ApiResponse<InlineResponse200> resp = whateverGetWithHttpInfo();
        return resp.getData();
    }

If i put the schema directly, without using the $ref, the generated code is having the return statement.

Swagger-codegen version

3.0.65

Swagger declaration file content or url
openapi: 3.0.1
paths:
  /whatever:
    get:
      responses:
        "200":
          $ref: "#/components/responses/WhateverGetResponse"

components: 
  responses: 
    WhateverGetResponse:
      description: test
      content:
        application/json:
          schema:
            type: object
            properties:
              name:
                type: string
Command line used for generation

java -jar ~/Downloads/swagger-codegen-cli-3.0.65.jar generate -i test.yaml -l java -o ./debug -DhideGenerationTimestamp=true

Steps to reproduce

just generate with 3.0.65

Related issues/PRs
Suggest a fix/enhancement

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions