Nomenclature
- Schema:
- 1. A representation of a plan or theory in the form of an outline or model.
- 2. (in Kantian philosophy) a conception of what is common to all members of a class; a general or essential type or form.
- Plural:
- Schemata, but also Schemas
Why use schemas?
- Establish canonical expectations for the data you send and receive
- Document your data structures
- Keeps documentation close to code
- Automate human readable documentation
- Automate machine readable documentation
- Automatic transformation between representations
- Clojure ⇒ [ JSON, YAML, XML, etc. ]
- [ JSON, YAML, XML, etc. ] ⇒ Clojure
(eg. JSON doesn't have keywords or dates)
- Generate valid, random data for property-based testing
Isn't this just static typing?
No
Schema validation only occurs when you want it.
Unlike many familiar type systems schemas provided
both more relaxed and more strict definitions.
There will be examples.