Describe the bug
oas3-valid-media-example doesn't flag the stray field provided in the media example as an error
To Reproduce
Given this OpenAPI/AsyncAPI document (name.yaml)
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
description: Sample OpenAPI Spec with a Schema
paths:
/sample:
get:
summary: Get Sample Data
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/SampleSchema'
example:
name: null # this is caught by the spectral rule
dateOfBirth: 1990-01-01
status: test # this not caught by the spectral rule until the first error (name) is fixed
age: 12 # this does not exist in the schema
components:
schemas:
SampleSchema:
type: object
properties:
name:
type: string
example: John Doe
dateOfBirth:
type: string
format: date
example: 1990-01-01
status:
type: string
enum:
active
inactive
example: active
2. the following spectral rule: (.spectral.yml)
```yaml
extends: spectral:oas
Run this CLI command '....'
spectral lint --ruleset=.spectral.yml name.yaml
Expected behavior
The rule should flag the stray field provided in the example (i.e age) since it does not exist in the schema
If an example is bad, it stops at the first bad example and doesn't process others until you fix it. I believe it should catch all instead of fail on first for example evaluation
Describe the bug oas3-valid-media-example doesn't flag the stray field provided in the media example as an error
To Reproduce
paths: /sample: get: summary: Get Sample Data responses: '200': description: Successful response content: application/json: schema: $ref: '#/components/schemas/SampleSchema' example: name: null # this is caught by the spectral rule dateOfBirth: 1990-01-01 status: test # this not caught by the spectral rule until the first error (name) is fixed age: 12 # this does not exist in the schema
components: schemas: SampleSchema: type: object properties: name: type: string example: John Doe dateOfBirth: type: string format: date example: 1990-01-01 status: type: string enum:
Expected behavior
example
(i.eage
) since it does not exist in the schemaEnvironment (remove any that are not applicable):