Closed toomuchdesign closed 3 years ago
The schema you have after applying the patch is this:
{
"CartItemMusementGiftbox": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/CartItem"
},
{
"properties": {
"type": {
"type": "string",
"enum": ["musement-giftbox"]
},
"product": {
"$ref": "#/components/schemas/Giftbox"
}
},
"type": "object"
}
],
"required": ["type", "product"]
}
}
I'm not sure this is a valid OpenApi format,
You could overwrite the whole CartItemMusementGiftbox
model with this patch:
{
"CartItemMusementGiftbox": {
"allOf": [
{
"$ref": "#/components/schemas/CartItem"
},
{
"properties": {
"type": {
"type": "string",
"enum": ["musement-giftbox"]
},
"product": {
"$ref": "#/components/schemas/Giftbox"
}
},
"type": "object",
"required": ["type", "product"]
}
]
}
}
Yep, that was definitely the issue! I didn't realize the patch was actually meant to be merged with the original schema. 👍
Thanks so much 🙌
I'm using this library against
https://api.musement.com/swagger_3.4.0.json
and heavily relying on--patchSource
option to patch the original swagger definition and manually set the required props.I found out that a few entities don't receive the required attributes specified in the patch file:
Patch file
Output
It seems to happen with types declared as union of other types. I noticed that the declaration shows and extra
& {}
appended at the and of it. Could it be that the patch gets applied to this empty object type?