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

Cleaning schemas a bit. #44

Open
stefalce opened this issue Aug 17, 2021 · 2 comments
Open

Cleaning schemas a bit. #44

stefalce opened this issue Aug 17, 2021 · 2 comments

Comments

@stefalce
Copy link

Here are some things I didn't find cool about json schemas:

  • type Int is out of the documentation but its schema is still present.
  • little endian numbers are not in the specification docs but have schemas.
  • the datatype.json schema seems to be unused by the validator (something else may depend on it).
  • the latest version of ajv errors because strict mode isn't respected.

The strict mode error doesn't mean much except the schema has something unclear or meaningless. Validation for strict mode or not is identical. For example in the container schema there is a non necessary additionalItems which annoyingly throws an error if strict mode is on.

{
   "type":"array",
   "items":{
      "type":"object",
      "properties":{
         "anon":{
            "type":"boolean"
         },
         "name":{
            
         },
         "type":{
            "$ref":"dataType"
         }
      },
      "oneOf":[
         {
            "required":[
               "anon"
            ]
         },
         {
            "required":[
               "name"
            ]
         }
      ],
      "required":[
         "type"
      ],
      "additionalProperties":false
   },
   "additionalItems":false
}
@stefalce
Copy link
Author

I've done more tests, I found a problem in cstring. Since it hasn't 'type: "array"' it validates all non array data as true. Also currently json like ["container"] or [] is considered valid (at least in newer versions), ajv strict mode is useful as it requires to state minItems. Schemas could also be rewritten using the const keyword instead of the single item enum.

@rom1504
Copy link
Member

rom1504 commented Feb 9, 2024

Please propose PRs for fixes

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

2 participants