spectral
spectral copied to clipboard
oas3-valid-media-example is reported for primitives if type is object
Describe the bug According to https://spec.openapis.org/oas/v3.0.3#schema-object object can also be primitive values but spectral seems to flag examples using primitives as invalid
To Reproduce
- Given this this schema
schema:
ApiError:
type: object
properties:
detail:
type: string
error:
type: integer
format: int32
parameters:
type: array
description: Parameter used to give more information about the error.
items:
type: object
an example like
example:
error: 400
detail: "Example"
parameters:
- "0"
- Run this CLI command
spectral lint
with the defaultextends: [spectral:oas]
rule sets - See error
error oas3-valid-media-example "0" property type must be object components.responses.badRequest.content.application/json.example.parameters[0]
Expected behavior Object examples should accept primitives according to the spec
Environment (remove any that are not applicable):
- CLI version 6.11.0