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
This adds support for the OpenAPI 3.1 schema dialect (`discriminator`
keyword) as well as a schema for validating OpenAPI 3.1 documents.
The dialect is a direct copy of the published schema, similar to the
regular JSON Schema drafts.
`discriminator` is not well defined in the spec and `skip_ref_once!` is
a little janky, but I think this should work and at least it's contained
within that vocab.
The document schema is modeled after the one from this article:
http://json-schema.org/blog/posts/validating-openapi-and-json-schema
with support for all of the existing JSON Schema dialects. There's some
complexity around `jsonSchemaDialect` and `$schema` which is meant to
support validating embedded schemas using the defined (or default)
dialect. It works well for OpenAPI 3.1 and Draft 2020-12 schemas because
they both use `"dynamicAnchor": "meta"`, but earlier drafts will have
trouble with nested schemas that use a different `$schema`. Subschemas
also use `jsonSchemaDialect` instead of inheriting `$schema` from their
parent, so it's probably best to set an explicit `$schema`.
`JSONSchemer.openapi` returns a simple `JSONSchemer::OpenAPI` helper
object with methods for validating the document and for using embedded
schemas to validate data. I'm not sure exactly what will be useful for
people so the API may change in the future.
The `json_schemer` executable takes a JSON schema file as the first argument followed by one or more JSON data files to validate. If there are any validation errors, it outputs them and returns an error code.
0 commit comments