From 2af6ae4a1700fe15ebc2af19633102e85d948fca Mon Sep 17 00:00:00 2001 From: newt10 Date: Thu, 9 Sep 2021 18:33:42 -0700 Subject: [PATCH] Documentation updates --- docs/4.x upgrade guide.md | 27 +++++++++++++++++++++++++++ docs/api-reference/form-props.md | 2 +- docs/usage/validation.md | 12 ++++++------ 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 docs/4.x upgrade guide.md diff --git a/docs/4.x upgrade guide.md b/docs/4.x upgrade guide.md new file mode 100644 index 0000000000..fa30fe3d96 --- /dev/null +++ b/docs/4.x upgrade guide.md @@ -0,0 +1,27 @@ +# 4.x Upgrade Guide + +## Breaking changes + +### Breaking changes due to Ajv v7 + +The following is a list of changes due to Ajv update to v7. + +#### JSON Schema draft-04 + +This version drops support for JSON schema draft-04. +You can update your schema to the specs of draft-07 using [ajv-cli](https://www.npmjs.com/package/ajv-cli). + +#### Object property name restrictions + +The following characters may cause unexpected behavior when used in property names: +- / +- [ +- ] + +If you are using any of these in your property names, you should change them or continue using 3.x until EOL. + +## New + +### Schema warnings + +If your schema does not pass the strict types check, you will see warnings printed to stderr/console. Your form will work as expected even with the warnings. You should aim to fix the schema to avoid the warnings as these schemas will not be accepted in the next major version. \ No newline at end of file diff --git a/docs/api-reference/form-props.md b/docs/api-reference/form-props.md index 44a10229c2..02d944cd6f 100644 --- a/docs/api-reference/form-props.md +++ b/docs/api-reference/form-props.md @@ -12,7 +12,7 @@ Note that this just renders the `action` attribute in the HTML markup. There is ## additionalMetaSchemas -This prop allows you to validate the form data against another JSON Schema meta schema, for example, JSON Schema draft-04. See [Validation](../usage/validation.md) for more information. +This prop allows you to validate the form data against another JSON Schema meta schema, for example, JSON Schema draft-06. See [Validation](../usage/validation.md) for more information. ## ArrayFieldTemplate diff --git a/docs/usage/validation.md b/docs/usage/validation.md index 5e8cd19042..847355e43b 100644 --- a/docs/usage/validation.md +++ b/docs/usage/validation.md @@ -177,7 +177,7 @@ To have your schemas validated against any other meta schema than draft-07 (the ```json { - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "http://json-schema.org/draft-06/schema#", ... } ``` @@ -186,22 +186,22 @@ Note that react-jsonschema-form only supports the latest version of JSON Schema, ### additionalMetaSchemas -The `additionalMetaSchemas` prop allows you to validate the form data against one (or more than one) JSON Schema meta schema, for example, JSON Schema draft-04. You can import a meta schema as follows: +The `additionalMetaSchemas` prop allows you to validate the form data against one (or more than one) JSON Schema meta schema, for example, JSON Schema draft-06. You can import a meta schema as follows: ```jsx -const metaSchemaDraft04 = require("ajv/lib/refs/json-schema-draft-04.json"); +const metaSchemaDraft06 = require("ajv/lib/refs/json-schema-draft-06.json"); ``` -In this example `schema` passed as props to `Form` component can be validated against draft-07 (default) and by draft-04 (added), depending on the value of `$schema` attribute. +In this example `schema` passed as props to `Form` component can be validated against draft-07 (default) and by draft-06 (added), depending on the value of `$schema` attribute. ```jsx const schema = { - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "http://json-schema.org/draft-06/schema#", type: "string" }; return (
); + additionalMetaSchemas={[metaSchemaDraft06]} />); ``` ## customFormats