Description I am trying to expose an internal API for customers to use. For this; I am generating the Swagger api-docs from the API response, and generating the YAML file with it.
Then to the YAML file I am using 'openapi-generator-maven-plugin' to create the model files that will point to internal code for the external users to view the response.
openapi-generator version spring-boot: 2.3.2.RELEASE Java: 1.8 okhttp: 4.8.1 gson: 2.8.6 openapitools: 4.3.1 code-findbugs: 3.0.2
OpenAPI declaration file content or url I have in response:
{
"offset": 0,
"limit": 200,
"total": 136,
"status": {
"code": 200,
"message": "Success"
},
"count": 136,
"reponseLastModified": "2020-09-02T20:56:57.951+0000",
"adjustments": [
{
"name1": "value1",
"name2": value2,
"name3": value3,
"name4": "value4"
},
{
"name1": "value1",
"name2": value2,
"name3": value3,
"name4": "value4"
}
]
}
For the above, I generated the Swagger JSON and converted to YAML code(removing some parts):
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/AdjustmentResponse'
AdjustmentResponse:
type: object
properties:
offset:
type: integer
description: 'The number of items to offset the start of the list from.'
format: int32
example: 5
limit:
type: integer
description: 'The number of items you want the list to be limited to.'
format: int32
example: 10
total:
type: integer
description: 'The total number of items that are in the entire collection.'
format: int32
example: 50
count:
type: integer
format: int32
reponseLastModified:
type: string
adjustments:
type: array
items:
$ref: '#/components/schemas/Adjustment'
Adjustment:
type: object
properties:
name1:
type: string
description: 'ABCD'
name2:
type: integer
description: 'ABCD'
example: 39
name3:
type: string
description: 'ABCD'
name4:
type: integer
description: 'ABCD'
example: 39
Generation Details As above
Steps to reproduce When I generate the Models, it will generate the models but will not generate the response API from what I generated the Swagger.
Changing the YAML file to below will generate the response but then the model file 'Adjustment' does not get generated since in AdjustmentResponse DTO it shows up as: List adjustments.
....
adjustments:
items:
$ref: '#/components/schemas/Adjustment'
Adjustment:
type: array
.....