OpenAPITools / OpenAPITools/openapi-generator
[BUG] Inconsistencies between pojo responses vs pojo models
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
I noticed two annoying differences in terms of generated Java sources depending on whether a structure is defined
- in the "responses" section
- in the "definitions" section
Issue#1
Given the following openapi file:
responses:
FooList:
schema:
title: fooList
type: object
xml:
name: fooList
definitions:
FooList2:
title: fooList2
type: object
xml:
name: fooList2
The value of "xmlName" mustache variable is
- "FooList" (wrong) for the response pojo
- "fooList2" (correct) for the model pojo
The consequence is that the root element of a XML response may be not compliant with the spec
(eg <FooList> instead of <fooList>)
Issue#2
Given the following openapi file:
responses:
Foo:
type: object
properties:
A:
B:
C:
D:
definitions:
Bar:
type: object
properties:
A:
B:
C:
D:
The order of the produced java members, eg:
{{#vars}}{{name}}{{{/vars}}
in pojo.mustache file, is not the same:
- is shuffled (B, C, A, D) for response pojo (Foo)
- is preserved (A, B, C, D) for model pojo (Bar)
The consequence is that the produced XML response may be not compliant with the spec (invalid order elements)- even if enriching the template with a specific order (by looping through the vars)
@XmlType(propOrder = { {{#vars}}"{{name}}",{{/vars}} })
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
Reproduce the supplied OpenAPI examples with the jaxrs-spec generator and compare generated Java sources for schemas under responses and definitions. Start with pojo.mustache and the response/model generation paths; done means xmlName follows the XML name and generated member order is preserved consistently for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100