Closed glennsc closed 1 year ago
Hi,
thanks for asking.
It's a bit hard to draw conclusions based on what is written above.
The error itself is a typical fastify
error, not fastify-openapi-glue
.
I think its caused by fastify's setting of strict mode
as a default parameter to AJV.
I ran into a similar issue with the PetStore example.
The solution there was to add an explicit option to fastify:
Hope this helps!
Kind regards, Hans
ps. you can also add such flags directly to fastify on startup: https://www.fastify.io/docs/latest/Reference/Server/#factory-ajv
Thank you so much for the fast response. Indeed, turning that ajv strict mode off worked. Deeply appreciated.
I build out an OpenAPI spec in Stoplight Studio, export the bundled ref to a .yaml file and use that in my fastify app as the spec for
fastify-openapi-glue.
. It worked until I started embedding $refs to models, and now I get validation errors for specific keywords in the model, such as:If I extract just the relevant
POST
from that spec:... no examples here, but you will see there are to $refs: one to an
Address
response and one to anAddressRequest
request body.In the response schema, there is a reference to an
Address
model. That model has many examples in it. An excerpt:If I remove the examples such as the one above the schema validates.
Debugging this has been a little difficult for me. I can't tell if the problem is in Fastify,
fastify-openapi-glue
, Ajv, or perhaps Stoplight is bundling the references incorrectly? Is it when $refs are layered two levels deep?I should point out that the
example
keyword won't validate when embedded in a ref, nor will any keyword that starts with "x-" such asx-stoplight
orx-tags.
The full error: