Skip to content

paulfouquet/oneOf-ex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oneOf-ex

This is an example to show that jsonschema-rs (Python) does not return nested errors when a field in oneOf is not matching the correct type. However, AJV (Javascript) returns the nested errors.

Requirements

poetry yarn

Run

jsonschema-rs (Python)

poetry install
poetry shell
python main.py

AJV (Javascript)

yarn
yarn index

Output

/oneOf-ex$ yarn index
Error for single schema:  /properties/id   must be string
Error for dual schema:  /properties/id   must be string
Error for dual schema:  /category   must be equal to constant
Error for dual schema:     must match exactly one schema in oneOf
Error for dual conditional schema:  /properties/id   must be string
/oneOf-ex$ python main.py
Error for single schema:  1234 is not of type "string"
Error for dual schema:  {"category":"CatA","properties":{"id":1234}} is not valid under any of the given schemas
Error for dual conditional schema:  1234 is not of type "string"

About

JSONSchema validation example with `oneOf`

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published