I'm manually writing swagger documentation. But I'm getting some error Should be object
I don't know why I'm getting error in below code.
events:
$ref: "#/def/Events"
Events:
type: "object"
properties:
oneOf:
- $ref: '#/def/ClassRef'
- $ref: '#/def/TypeRef'
- $ref: '#/def/EventRef'
- $ref: '#/def/MarketRef'
- $ref: '#/def/OutcomeRef'
ClassRef: # <--- I get the "should be object" error here
type: "object"
properties:
classRef:
type: "string"
TypeRef:
type: "object"
properties:
typeRef:
type: "string"
EventRef:
type: "object"
properties:
eventRef:
type: "string"
MarketRef:
type: "object"
properties:
marketRef:
type: "string"
OutcomeRef:
type: "object"
properties:
outcomeRef:
type: "string"
I'm getting this error in ClassRef line. Can some one help me please
OpenAPI 2.0 (swagger: '2.0') does not support oneOf, you need OpenAPI 3.0 (openapi: 3.0.0) to use oneOf.
Assuming you use OpenAPI 3.0, and all schemas live in the components/schemas section, change the Events schema as follows:
Events:
oneOf:
- $ref: '#/components/schemas/ClassRef'
- $ref: '#/components/schemas/TypeRef'
- $ref: '#/components/schemas/EventRef'
- $ref: '#/components/schemas/MarketRef'
- $ref: '#/components/schemas/OutcomeRef'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With