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

schema.json is invalid #29

Open
IMD-Solutions-xyz opened this issue Aug 21, 2022 · 1 comment
Open

schema.json is invalid #29

IMD-Solutions-xyz opened this issue Aug 21, 2022 · 1 comment

Comments

@IMD-Solutions-xyz
Copy link

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
Copy link
Author

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

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

1 participant