[x3d-public] Using draft 07 with latest Ajv2019 classes.

John Carlson yottzumm at gmail.com
Sat May 8 07:18:36 PDT 2021


This looks like how to support older versions of JSON schema with current
Ajv:

https://github.com/ajv-validator/ajv-formats

I will work on installing this in my packages.

John

On Fri, May 7, 2021 at 11:03 PM John Carlson <yottzumm at gmail.com> wrote:

> The new version 8 of ajv appears to support draft 07 by adding a schema
> to Ajv2019 class instance, but I tried with the Ajv class instance, and
> it didn't work.
>
> https://ajv.js.org/guide/schema-language.html
>
> describes how to use draft07 with Ajv2019.
>
> So if anyone wants to attempt to use draft 07 with the latest Ajv, that
> would be cool.
>
> The main problem appears to be "uri"
>
> Here are the changed I tried:
>
>
> ~/x3dvalidate$ git diff .
> diff --git a/index.js b/index.js
> index 6deeccb..e3b5bb1 100644
> --- a/index.js
> +++ b/index.js
> @@ -1,5 +1,7 @@
>   "use strict";
> -var Ajv = require('ajv');
> +var Ajv = require('ajv/dist/2019');^M
> +const draft7MetaSchema =
> require("ajv/dist/refs/json-schema-draft-07.json")
> +
>   var fs = require('fs');
>   var http = require('http');
>   var jsonlint = require('jsonlint');
> @@ -82,6 +84,7 @@ function loadSchema(json, file, doValidate, success,
> failure, language) {
>                  console.error("Adding meta schema");
>                  ajv.addMetaSchema(metaschemajson);
>                  */
> +               ajv.addMetaSchema(draft7MetaSchema)
>                  console.error("Loading schema");
>                  var schema =
> fs.readFileSync("x3d-"+version+"-JSONSchema.json");
>                  console.error("Parsing schema");
>
>
> Thanks,
>
> John
>
> On 5/7/21 9:50 PM, John Carlson wrote:
> > This seems to work in x3dvalidate
> > https://github.com/coderextreme/x3dvalidate
> >
> > ~/x3dvalidate$ cat package.json
> > {
> >   "name": "x3dvalidate",
> >   "version": "1.0.0",
> >   "private": true,
> >   "dependencies": {
> >     "ajv": "^6.12.6",
> >     "ajv-i18n": "^3.6.0",
> >     "jsonlint": "https://github.com/prantlf/jsonlint.git"
> >   }
> > }
> >
> >
> > I am going with an old version of ajv which still supports draft 07
> > because the latest does not recognize "uri"
> >
> > Best of luck, I will work on upgrading X3DJSONLD and pythonSAI next.
> >
> >
> > John
> >
> > On 5/7/21 9:20 PM, John Carlson wrote:
> >> The main issue appears to be that jsonlint is out of date with
> >> current packages (nomnom has been withdrawn).  If someone works on a
> >> fix for this, that would be great.
> >>
> >> It appears that some people are using:
> >>
> >> "@gerhobbelt/nomnom": "^1.8.4-27"
> >>
> >> https://github.com/zaach/jsonlint/pull/120/files
> >>
> >> This was not obvious until I got to x3dvalidate.
> >>
> >> I don't know how to override the nomnom package in package.json or
> >> package-lock.json
> >>
> >> Help would be appreciated!
> >>
> >> On 5/7/21 8:34 PM, John Carlson wrote:
> >>> $ grep -l underscore */package-lock.json
> >>> pc.multiplayer/package-lock.json
> >>> pythonSAI/package-lock.json
> >>> X3DJSONLD/package-lock.json
> >>> x3droundtrip/package-lock.json
> >>> x3dvalidate/package-lock.json
> >>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20210508/cc99dd8b/attachment.html>


More information about the x3d-public mailing list