You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a API designer, I can use Spectral to validate examples and clearly see which unevaluated properties exist, so that I can update my examples to be correct
Is your feature request related to a problem?
Yes. When Spectral checks examples against a schema, and the schema has
unevaluatedProperties: false
and the schema example or examples contains unexpected properties,
Spectral just shows:
error oas3-valid-schema-example "example" property must not have unevaluated properties
Describe the solution you'd like
When there are unevaluated properties, list which properties are not evaluated.
Additional context
Here is a sample openapi.yaml source file:
openapi: 3.1.0info:
title: Unevaluated Propertydescription: OpenAPIwith invalid schema example (unevaluated property)version: "1.0.0"contact: {}tags:
- name: Exampledescription: Exampleservers:
- url: https://www.example.com/apipaths:
/present:
get:
summary: Get a presentdescription: Get a presentoperationId: getAPresenttags:
- Exampleresponses:
'200':
description: OKcontent:
application/json:
schema:
$ref: '#/components/schemas/present'4XX:
description: OKcontent:
application/json:
schema:
type: objectcomponents:
schemas:
present:
title: A presenttype: objectunevaluatedProperties: falseproperties:
openedOn:
description: The date the present was opened.type: stringformat: dateminLength: 10maxLength: 10receivedOn:
description: The date the present was received.type: stringformat: dateminLength: 10maxLength: 10example:
recievedOn: 2024-12-25openedOn: 2024-12-25
running
$ spectral lint -r ~/config/oas-spectral-ruleset.yaml openapi.yaml
55:15 error oas3-valid-schema-example "example" property must not have unevaluated properties components.schemas.present.example
✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints)
This only tells me the example must not have unevaluated properties, but this is not specific enough.
In this case, it is not to hard to deduce the problem (receivedOn was misspelled as recievedOn)
but in real world examples where a schema may have many properties (especially when
composing schemas with allOf), it is not immediately obvious which properties
are not defined with a properties constraint. I'd like to see the violations listed, such as:
55:15 error oas3-valid-schema-example "example" property must not have unevaluated properties:
components.schemas.present.example
- recievedOn is not evaluated
Note: My ruleset file contains:
extends:
- spectral:oas
The text was updated successfully, but these errors were encountered:
User story.
As a API designer, I can use Spectral to validate examples and clearly see which unevaluated properties exist, so that I can update my examples to be correct
Is your feature request related to a problem?
Yes. When Spectral checks examples against a schema, and the schema has
and the schema
example
orexamples
contains unexpected properties,Spectral just shows:
Describe the solution you'd like
When there are unevaluated properties, list which properties are not evaluated.
Additional context
Here is a sample openapi.yaml source file:
running
This only tells me the
example
must not have unevaluated properties, but this is not specific enough.In this case, it is not to hard to deduce the problem (
receivedOn
was misspelled asrecievedOn
)but in real world examples where a schema may have many properties (especially when
composing schemas with
allOf
), it is not immediately obvious which propertiesare not defined with a
properties
constraint. I'd like to see the violations listed, such as:Note: My ruleset file contains:
The text was updated successfully, but these errors were encountered: