highsource / highsource/jsonix

AJV JSON Schemas Draft 06 Support Update

Open
#178 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
369
Forks
85
PR merge metrics
No merged PRs in 30d

Description

AJV@5 or above cannot add XMLSchema.jsonschema

Requires migration as per AJV (https://github.com/epoberezkin/ajv/releases/tag/5.0.0)

>
> **## Migrate your schemas**
>
> It is a recommended approach.
>
> **Required changes**
>
> - replace id with $id
> - update $schema
> - replace boolean form of exclusiveMaximum/Minimum with numeric form
> - replace Ajv v5 constant with const
>
> **Optional changes**
>
> - replace enum with a single allowed value with const
> - replace empty schemas with true
> - replace schemas {"not":{}} with false
> - You can use "migrate" command of ajv-cli to make these changes to your schemas.
>
> _**You can use "migrate" command of ajv-cli to make these changes to your schemas.**_

Either we can update docs to keep using Draft04 of JSON schema with following info :

> If you need to continue using draft-04 schemas
> ```
> var ajv = new Ajv({
> meta: false, // optional, to prevent adding draft-06 meta-schema
> extendRefs: true, // optional, current default is to 'fail', spec behaviour is to 'ignore'
> unknownFormats: 'ignore', // optional, current default is true (fail)
> // ...
> });
>
> var metaSchema = require('ajv/lib/refs/json-schema-draft-04.json');
> ajv.addMetaSchema(metaSchema);
> ajv._opts.defaultMeta = metaSchema.id;
>
> // optional, using unversioned URI is out of spec, see https://github.com/json-schema-org/json-schema-spec/issues/216
> ajv._refs['http://json-schema.org/schema'] = 'http://json-schema.org/draft-04/schema';
>
> // Optionally you can also disable keywords defined in draft-06
> ajv.removeKeyword('propertyNames');
> ajv.removeKeyword('contains');
> ajv.removeKeyword('const');
> ```
>

Or we can update jsonschemas using "migrate" command of ajv-cli ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.