Validate JSON Schema documents with Org mode
- Validate JSON literals
#+NAME: org-src-json-schema-literals #+BEGIN_SRC shell :results pp curl -s https://assertible.com/json -d '{ "schema": {}, "json": {} }' | jq . #+END_SRC #+RESULTS: org-src-json-schema-literals : { : "errors": [], : "valid": true : }
- Validating JSON Schema files
#+NAME: org-src-json-schema-files #+BEGIN_SRC shell :results pp SCHEMA=$(cat $HOME/api-json-schema.json) JSON=$(cat $HOME/api-response-json-schema.json) curl -s https://assertible.com/json -d "{ \"schema\": $SCHEMA, \"json\": $JSON }" | jq . #+END_SRC #+RESULTS: org-src-json-schema-files : { : "errors": [], : "valid": true : }
- Good validation errors
The Assertible JSON Schema Validation API gives back decent errors too
#+NAME: org-src-json-schema-errors #+BEGIN_SRC shell :results pp curl -s https://assertible.com/json -d '{ "schema": {"type":"object"}, "json": null }' | jq .errors[] #+END_SRC #+RESULTS: org-src-json-schema-errors : "failed to validate type - `null` is not a object"