Hi!
I’m new using Openapi and I got an error from Spectral that I don’t know how to fix it.
I reduced the yaml to be easier to analyse:
openapi: 3.0.0
tags:
- name: Preview
info:
version: 1.0.0
title: lala
contact:
name: Team X
url: 'http://lala.com'
description: Lala
servers:
- url: https://lala.com
description: lala
components:
schemas:
Default:
type: object
properties:
url:
type: string
nullable: true
Audio:
allOf:
- $ref: '#/components/schemas/Default'
- type: object
properties:
audio_url:
type: string
nullable: false
paths:
'/lala/{id}':
parameters:
- schema:
type: string
name: id
in: path
required: true
description: lala
get:
description: Returns lala
tags:
- Preview
parameters:
- in: query
name: id
description: 'lala'
schema:
type: string
example: 2c0ed7250ea9c8b65c18dfbf4efdff73b9aedf38
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
previews:
type: object
additionalProperties:
oneOf:
- $ref: '#/components/schemas/Default'
- $ref: '#/components/schemas/Audio'
example:
previews:
abc123aa:
url: https://example.com/preview1.jpeg
sdja6tsj:
url: null
audio_url: https://example.com/audio.jpeg
operationId: lala
summary: lala
When I run spectral, it shows:
67:28 error oas3-valid-oas-content-example abc123aa
property oneOf should match exactly one schema in oneOf
Could someone help me how to fix that pls?