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
Description:
I'm encountering an issue with Spectral when validating an OpenAPI 3.0.0 document. The error is raised in the example section of a schema definition. The issue seems to be related to the presence of the type: HEADER property within the example, which causes Spectral to throw a validation error. However, when the type property is removed from the example, the validation passes without any errors.
OpenAPI Document:
Here's a minimal reproducible example of the OpenAPI document that triggers the issue:
openapi: 3.0.0info:
title: ''version: '1.0'paths: {}components:
schemas:
Template:
type: objecttitle: ''description: Message Templateproperties:
components:
type: arrayitems:
type: objectproperties:
type:
type: stringenum:
- HEADER
- BODY
- BUTTONS
- FOOTERexample: BODYtext:
type: stringexample: >- hello {{var_1}}, we have an upcoming mega sale event at {{var_2}}, please check attached locationexample:
type: objectproperties:
month:
type: stringexample:
components:
- text: '{{month}} Sale Offer'type: HEADERexample:
month: June
Error Message:
When running Spectral, I receive the following error:
schema is invalid: data/type must be equal to one of the allowed values, data/type must be array, data/type must match a schema in anyOf
Steps to Reproduce:
Create an OpenAPI 3.0.0 document with the schema definition provided above.
Run the Spectral linter on the document (Or paste it in stoplight app).
Observe the validation error reported by Spectral.
Additional Context:
The error appears to be associated with the type: HEADER field within the example.
If the type: HEADER is removed from the example, the validation passes without any errors.
Expected Behavior:
The example should be considered valid by Spectral, or the error message should clearly explain why the example is invalid according to the OpenAPI specification.
Environment:
Spectral version: Using stoplight app
OpenAPI version: 3.0.0
Attaching the screenshot for reference.
With error
Without error (commented type)
The text was updated successfully, but these errors were encountered:
sandeep2rawat
changed the title
Schema Validation Error for Example in OpenAPI 3.1.0 Document
Schema Validation Error for Example in OpenAPI 3.0.0 Document
Aug 16, 2024
Description:
I'm encountering an issue with Spectral when validating an OpenAPI 3.0.0 document. The error is raised in the
example
section of a schema definition. The issue seems to be related to the presence of thetype: HEADER
property within the example, which causes Spectral to throw a validation error. However, when thetype
property is removed from the example, the validation passes without any errors.OpenAPI Document:
Here's a minimal reproducible example of the OpenAPI document that triggers the issue:
Error Message:
When running Spectral, I receive the following error:
Steps to Reproduce:
Additional Context:
type: HEADER
field within the example.type: HEADER
is removed from the example, the validation passes without any errors.Expected Behavior:
The example should be considered valid by Spectral, or the error message should clearly explain why the example is invalid according to the OpenAPI specification.
Environment:
Attaching the screenshot for reference.
With error
Without error (commented type)
The text was updated successfully, but these errors were encountered: