i use OpenAPI Generator to generate client on based my swagger.yaml i have this part of code:
...
responses:
'400':
$ref: "#/errors/400"
...
errors:
'400':
description: invalid request
content:
application/json:
schema:
$ref: "#/components/schemas/ErrResp"
...
components:
schemas:
ErrResp:
type: object
properties:
error_code:
$ref: "#/components/schemas/ErrCode"
error_msg:
type: string
ErrCode:
type: integer
description: |
2 - invalid request
...
Generation is performed using this command:
openapi-generator generate -i myAPI.yaml -g typescript-fetch -o ./myAPI"
and have warning:
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/errors/400
At the same time, the check for editor.swagger.io passes without errors and warnings - the file is described correctly. I temporarily found the following solution on how to avoid this warning, but I want to find out why it occurs, and I would like to keep the current structure in order to avoid redundancy.
The solution is: Instead
responses:
'400':
$ref: "#/errors/400"
the following is used, in which case there are no warnings:
responses:
'400':
description: invalid request
content:
application/json:
schema:
$ref: "#/components/schemas/ErrResp"