Forum Discussion
-
HKosovaSmartBear Alumni (Retired)
It's possible but cumbersome. You need to use anyOf , like this:
CheckResponse: type: object required: - check_completed properties: check_completed: type: boolean check_details: $ref: '#/components/schemas/checkdetails' anyOf: - properties: check_completed: enum: [false] - properties: check_completed: enum: [true] required: - check_details
I would recommend describing this dependency in the schema/property descriptions instead.
OpenAPI 3.1 (future version) will make this easier thanks to using the latest JSON Schema which includes if...then..else among other things.
CheckResponse:: type: object required: - check_completed properties: check_completed: type: boolean check_details: $ref: '#/components/schemas/checkdetails'