Skip to content
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

No way to validate against custom $schema's #783

Closed
2 tasks done
dmakovec opened this issue Dec 5, 2017 · 2 comments
Closed
2 tasks done

No way to validate against custom $schema's #783

dmakovec opened this issue Dec 5, 2017 · 2 comments

Comments

@dmakovec
Copy link

dmakovec commented Dec 5, 2017

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

There doesn't seem to be a way to set up validation against custom schemata.

For documents which use a $schema URI other than "http://json-schema.org/draft-06/schema#" or similar, it's necessary to call Ajv's addSchema() method to pre-load the schema for validation against. There doesn't seem to be a way to do that at present?

Steps to Reproduce

Use a document with a custom $schema, e.g.

{
    "$schema": "https://my.example.site/schema#",
    "title": "Product",
    "description": "A product from Acme's catalog",
    "type": "object",
   ...
}

Expected behavior

Form is validated against that schema.

Actual behavior

JsonSchemaFormWrapper.js:166
Error: no schema with key or ref "https://my.example.site/schema"
ajv.js:95
    at Ajv.validate (/home/user/project/node_modules/ajv/lib/ajv.js:95:1)

    at Ajv.validateSchema (/home/user/project/node_modules/ajv/lib/ajv.js:179:8)

    at Ajv._addSchema (/home/user/project/node_modules/ajv/lib/ajv.js:311:1)

    at Ajv.validate (/home/user/project/node_modules/ajv/lib/ajv.js:97:1)

    at validateFormData (/home/user/project/node_modules/react-jsonschema-form/lib/validate.js:196:1)

    at Form.validate (/home/user/project/node_modules/react-jsonschema-form/lib/components/Form.js:166:1)

    at eval (/home/user/project/node_modules/react-jsonschema-form/lib/components/Form.js:87:1)

    at Form._this.onSubmit (/home/user/project/node_modules/react-jsonschema-form/lib/components/Form.js:103:10)

    at HTMLUnknownElement.callCallback (/home/user/project/node_modules/react-dom/cjs/react-dom.development.js:540:1)
....

Version

1.0.0

@handrews
Copy link

Hi folks- I'm dropping in from the JSON Schema spec team.

In the forthcoming draft-08, we will be adding features to make recognizing and working with custom meta-schemas (as indicated by $schema easier. We would welcome feedback on these proposals, starting with json-schema-org/json-schema-spec#561, and then json-schema-org/json-schema-spec#563 and json-schema-org/json-schema-spec#564

Incidentally, this would make it easy to model UI-related keywords as a JSON Schema vocabulary.

@epicfaace
Copy link
Member

I'm merging this issue into #794.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants