Reputation: 5
I use command below to merge many yaml file to one file json:
redocly bundle --dereferenced src/index.yaml --output dist/index.json
A part of file index.yaml:
responses:
'200':
description: "request thành công"
content:
application/json:
schema:
type: object
properties:
data:
$ref: "../common/responses.yaml#/field_group_object" # Pay attention to this line
code:
type: integer
example: 200
message:
type: string
example: request thành công
$ref: "../common/responses.yaml#/status" # Pay attention to this line
After run command. No error, but I check index.json:
"responses": {
"200": {
"description": "request thành công",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"$ref": "index.yaml#/components/schemas/field_group_object" # Error because index.json is combined to 1 file, it do not reference in other file in outside
},
"code": {
"type": "integer",
"example": 200
},
"message": {
"type": "string",
"example": "request thành công"
}
}
}
}
}
},
# this is $ref: "../common/responses.yaml#/status". It's work
"401": {
"description": "Token is invalid or is expired. Please login again.",
"content": {
Not error when running but
"$ref": "index.yaml#/components/schemas/field_group_object"
can not be used
because index.json is combined to 1 file, it do not reference in other file in outside
Thanks for reading!
Upvotes: 0
Views: 190