Skip to content

require $schema in schemas #1434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 20, 2023
34 changes: 23 additions & 11 deletions jsonschema-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -884,25 +884,37 @@ meta-schema features emphasizes flexibility over simplicity.

The `$schema` keyword is both used as a JSON Schema dialect identifier and as
the identifier of a resource which is itself a JSON Schema, which describes the
set of valid schemas written for this particular dialect.
set of valid schemas written for this particular dialect. The identified dialect
applies to the resource in which it is declared as well as any embedded schema
resources, unless such a resource itself declares a different dialect by
including the `$schema` keyword with a different value.

The value of this keyword MUST be a [IRI](#rfc3987) (containing a scheme) and
The value of this keyword MUST be an [IRI](#rfc3987) (containing a scheme) and
this IRI MUST be normalized. The current schema MUST be valid against the
meta-schema identified by this IRI.

If this IRI identifies a retrievable resource, that resource SHOULD be of media
type `application/schema+json`.

The `$schema` keyword SHOULD be used in the document root schema object, and MAY
be used in the root schema objects of embedded schema resources. It MUST NOT
appear in non-resource root schema objects. If absent from the document root
schema, the resulting behavior is implementation-defined, but MUST fall within
the following options:

- Refuse to process the schema, as with unsupported required vocabularies
- Assume a specific, documented meta-schema
- Document the process by which it examines the schema and determines which of a
specific set of meta-schemas to assume
be used in the root schema objects of embedded schema resources. When the
keyword appears in non-resource root schema object, the behavior is undefined.

If present in the resource root schema, an implementation MUST process the
schema in accordance with the associated dialect.

If absent from the resource root schema, and no parent dialect is defined, the
schema MUST be processed with the following priorities:

1. If the implementation accepts media type parameter inputs, and an
`application/schema+json` media type with a `schema` parameter is available,
then the schema MUST be processed in accordance with the dialect indicated by
the `schema` parameter.
2. An implementation MAY offer a mechanism for the user to explicitly set the
dialect.

If the dialect is not specified through one of these methods, the implementation
MUST refuse to process the schema, as with unsupported required vocabularies.

Values for this property are defined elsewhere in this and other documents, and
by other parties.
Expand Down