OpenAPITools / OpenAPITools/openapi-generator
[BUG] [jaxrs-spec] Invalid return type for responses of type array
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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

Environment:
- openapi-generator-maven-plugin
- version: 3.3.4
- generatorName: jaxrs-spec
- jdk1.8.0_191
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported response schema with the jaxrs-spec generator and inspect the generated JAX-RS interface and XML output. Compare the generated root element with the schema's XML name and the expected Swagger UI response; done means the XML response uses the specified assignments root while JSON behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100