Chia-Network / chips

Apache License 2.0
45 stars 22 forks source link

schema.json is invalid #29

Open IMD-Solutions-xyz opened 2 years ago

IMD-Solutions-xyz commented 2 years ago

Hi,

I was trying to validate the metadata JSON files against the https://github.com/Chia-Network/chips/blob/metadata-schema/assets/chip-0007/schema.json using https://github.com/ajv-validator/ajv-cli and I got "schema.json is invalid".

Steps to reproduce:

leonid@asus:~$ node -v
v16.16.0
leonid@asus:~$ npm -v
8.11.0
leonid@asus:~$ sudo npm install -g ajv-cli
...
leonid@asus:~$ ajv help

Validate data file(s) against schema
    ajv [validate] -s schema[.json] -d data[.json]
    ajv [validate] -s schema[.json] -d "data*.json"

Compile schema(s)
    ajv compile -s schema[.json]
    ajv compile -s "schema*.json"

Migrate schema(s) to draft-07 or draft-2019-09
    ajv migrate -s schema[.json] -o migrated_schema.json
    ajv migrate -s "schema*.json"

Test data validation result
    ajv test -s schema[.json] -d data[.json] --valid
    ajv test -s schema[.json] -d data[.json] --invalid
    ajv test -s schema[.json] -d "data*.json" --valid

options:
    --spec=            JSON schema specification to use
            draft7     JSON Schema draft-07 (default)
            draft2019  JSON Schema draft-2019-09

More information:
        ajv help validate
        ajv help compile
        ajv help migrate
        ajv help test
leonid@asus:~$

leonid@asus:~$ git clone https://github.com/Chia-Network/chips.git
Cloning into 'chips'...
remote: Enumerating objects: 607, done.
remote: Counting objects: 100% (139/139), done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 607 (delta 78), reused 130 (delta 70), pack-reused 468
Receiving objects: 100% (607/607), 2.41 MiB | 14.84 MiB/s, done.
Resolving deltas: 100% (275/275), done.
leonid@asus:~$ cd chips
leonid@asus:~/chips$ git checkout metadata-schema
Branch 'metadata-schema' set up to track remote branch 'metadata-schema' from 'origin'.
Switched to a new branch 'metadata-schema'
leonid@asus:~/chips$ cd assets/chip-0007/
leonid@asus:~/chips/assets/chip-0007$ ls -l
total 12
-rw-rw-r-- 1 leonid leonid 1880 Aug 21 10:36 example.json
-rw-rw-r-- 1 leonid leonid 5076 Aug 21 10:36 schema.json
leonid@asus:~/chips/assets/chip-0007$

leonid@asus:~/chips/assets/chip-0007$ ajv validate -s schema.json -d example.json --spec=draft2020
strict mode: use allowUnionTypes to allow union type keyword at "https://raw.githubusercontent.com/Chia-Network/chips/main/assets/chip-0007/schema.json#/properties/sensitive_content" (strictTypes)
strict mode: use allowUnionTypes to allow union type keyword at "https://raw.githubusercontent.com/Chia-Network/chips/main/assets/chip-0007/schema.json#/properties/attributes/items/properties/trait_type" (strictTypes)
strict mode: use allowUnionTypes to allow union type keyword at "https://raw.githubusercontent.com/Chia-Network/chips/main/assets/chip-0007/schema.json#/properties/attributes/items/properties/value" (strictTypes)
schema schema.json is invalid
error: unknown format "uuid" ignored in schema at path "#/properties/collection/properties/id"
leonid@asus:~/chips/assets/chip-0007$
IMD-Solutions-xyz commented 2 years ago

I do not get error(s) when trying to validate using https://github.com/python-jsonschema/jsonschema

leonid@asus:~/chips/assets/chip-0007$ jsonschema --version
3.2.0
leonid@asus:~/chips/assets/chip-0007$ jsonschema --help
usage: jsonschema [-h] [-i INSTANCES] [-F ERROR_FORMAT] [-V VALIDATOR] [--version] schema

JSON Schema Validation CLI

positional arguments:
  schema                the JSON Schema to validate with (i.e. schema.json)

optional arguments:
  -h, --help            show this help message and exit
  -i INSTANCES, --instance INSTANCES
                        a path to a JSON instance (i.e. filename.json) to validate (may be specified multiple times)
  -F ERROR_FORMAT, --error-format ERROR_FORMAT
                        the format to use for each error output message, specified in a form suitable for passing to str.format, which will be called with 'error' for each error
  -V VALIDATOR, --validator VALIDATOR
                        the fully qualified object name of a validator to use, or, for validators that are registered with jsonschema, simply the name of the class.
  --version             show program's version number and exit
leonid@asus:~/chips/assets/chip-0007$
leonid@asus:~/chips/assets/chip-0007$ jsonschema --instance example.json schema.json
leonid@asus:~/chips/assets/chip-0007$

Online validation using JSON Schema validator also seems to be OK, but I'm not sure whether it supports 2020-12 Draft - https://www.jsonschemavalidator.net/s/OaXy5bKL