hyperjump-io / json-schema

JSON Schema Validation, Annotation, and Bundling. Supports Draft 04, 06, 07, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1
https://json-schema.hyperjump.io/
MIT License
216 stars 22 forks source link

update openapi 3.1 base schema url #46

Closed Mearman closed 8 months ago

jdesrosiers commented 8 months ago

Thanks for the PR, but the example is correct as is. https://spec.openapis.org/oas/3.1/schema-base is what you should use to validate an OpenAPI document. https://spec.openapis.org/oas/3.1/dialect/base could be used if you have just a JSON Schema that needs validation using the OpenAPI JSON Schema dialect. However, a better way to validate a schema is just to compile it. It's better because it does additional validation that can't be done with meta-schema validation.

registerSchema({ type: "string" }, "https://example.com/string", "https://spec.openapis.org/oas/3.1/dialect/base");
const validator = validate("https://example.com/string"); // Will throw InvalidSchemaError if there's something wrong with the schema