Skip to content

having multiple responses in OpenAPI-3.0.0 schema cause faulty generated code  #3

Closed
@ljgw

Description

@ljgw

In swagger 2.0 schemata produces was a top level field with mime-types. In OpenApi 3.0.0 schemata media-types are used for this purpose and they are located differently, as key for MediaType-Objects in the content map. That means that if multiple responses are described, the same media-type can be used as a key in the response content maps.

However, when I try to use this new feature of OpenAPI 3.0.0, my generated java client code comes out faulty. Using this project to generate java code for the following schema-fragment

      responses:
        '200':
          description: pet response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

results in the following code

    final String[] localVarAccepts = {
      "application/json""application/json"
    };

because hasMore is incorrectly not added to the 'last content in the first response'.

Moreover, application/json appears twice in the codegenOperation.produces ArrayList because while each response yields a Set of media-type keys, those sets are combined into a List at the codegenOperation.produces level.

Metadata

Metadata

Assignees

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