Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [jaxrs-spec] Invalid return type for responses of type array #2243

Open
bligny opened this issue Feb 26, 2019 · 0 comments
Open

[BUG] [jaxrs-spec] Invalid return type for responses of type array #2243

bligny opened this issue Feb 26, 2019 · 0 comments

Comments

@bligny
Copy link

bligny commented Feb 26, 2019

The following OpenApi response:

responses:

  AssignmentList:   
    schema:
      type: array     
      xml:
        name: assignments
        namespace: 'http://...'
        wrapped: true
      items:
        $ref: '#/definitions/TourAssignment'

is generating the following JAXRS-interface:

@Path(...)
@Produces(...)
@ApiOperation(...)
@ApiResponses(value = { 
    @ApiResponse(..., response=TourAssignment.class, responseContainer="List")
    })
List<TourAssignment> myWebService(); 

Please note the return type of the web service: List<TourAssignment>
I was rather expecting a separate "AssignmentList" java class.

This is working very fine for json response:

[
    {
        "agentID": "bligny",
        "assignmentDate": "2019-02-26"
    }
]

but in case of xml, the produced response is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<collection xmlns:ns2="http://...">
    <ns2:assignment>
        <ns2:agentID>bligny</ns2:agentID>
        <ns2:assignmentDate>2019-02-26</ns2:assignmentDate>
    </ns2:assignment>
</collection>

This is in contradiction

  • with the specs which states that the root element should be named "assignments"
  • with the sample response generated by swagger-ui

image

Environment:

  • openapi-generator-maven-plugin
  • version: 3.3.4
  • generatorName: jaxrs-spec
  • jdk1.8.0_191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant