Open fabioperrella opened 3 years ago
@P0lip Does spectral support objects in additionalProperties?
Hi, I was able to solve this issue by adding a required field in the schema.
Adding all properties as required
is indeed a good workaround.
Shape:
oneOf:
- $ref: '#/components/schemas/Rectangle'
- $ref: '#/components/schemas/Circle'
discriminator:
propertyName: shapeType
mapping:
rectangle: '#/components/schemas/Rectangle'
circle: '#/components/schemas/Circle'
example:
shapeType: rectangle
width: 10
height: 20
Rectangle:
type: object
required: [shapeType, width, height] <-- all required
properties:
shapeType:
type: string
width:
type: number
height:
type: number
Circle:
type: object
required: [shapeType, radius] <-- all required
properties:
shapeType:
type: string
radius:
type: number
However, this should also validate fine:
Rectangle:
type: object
required: [shapeType] <-- only discriminator is required
properties:
shapeType:
type: string
width:
type: number
height:
type: number
Instead, this yields "0" property must match exactly one schema in oneOf
Describe the bug A clear and concise description of what the bug is.
Spectral is showing the error
oas3-valid-oas-content-example
in a scenario that I didn't expectTo Reproduce
paths: '/lala/{id}': parameters:
example: previews: abc123aa: url: https://example.com/preview1.jpeg sdja6tsj: url: null audio_url: https://example.com/audio.jpeg operationId: lala summary: lala
Expected behavior
I'm pretty sure I specified the example correctly and it shouldn't return an error
Environment (remove any that are not applicable):