my computing environment
by creichert
Recently, I helped implement a JSON Schema Validation API for Assertible that is free to use.
I manage a large portion of my agenda from org-mode
, and part of my job on the
front-line of support and customer interaction is to field requests about JSON
Schema. Naturally, it would make sense if I could seamlessly work with JSON
Schema documents from Org mode.
Here are some snippets I use to validate JSON Schema documents for assiting Assertible users and my own testing:
#+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
: }
#+NAME: org-src-json-schema-files
#+BEGIN_SRC shell :results pp
SCHEMA=$(cat $HOME/dev/rbros/assertible/test/data/simplyrets-api-json-schema.json)
JSON=$(cat $HOME/dev/rbros/assertible/test/data/simplyrets-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
: }
#+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"