Writing Domain Specific Languages
with JSON Schema
Yos Riady
yos.io
bit.ly/2JbMTrn
Slide 3
Slide 3 text
Weak types in JSON
What is JSON Schema?
Introduction Schema Uses DSL Conclusion
JSON Schema use
cases
Summary and further
learning
Writing a DSL with
JSON Schema
JSON Schema 101
Invalid Validation Message
{
“userName”: 1
}
Field .userName should be a string
{
“name”: “foo”
}
Should NOT have additional properties
{} Should have required property ‘userName’
Use Cases for JSON Schema
● Message / data validation
○ Object Relational Mappers (ORMs)
● Schemaless objects in Web Applications
● Content Management in Headless CMSes
● Writing Specification Languages
○ OpenAPI / Swagger
○ AWS States Language
○ WAML
Slide 23
Slide 23 text
Hapi.js object validation
Slide 24
Slide 24 text
Dynamic forms
Slide 25
Slide 25 text
Content Modeling in Headless CMSes
Slide 26
Slide 26 text
Content Modeling in Headless CMSes
Slide 27
Slide 27 text
Writing Specification Languages
Slide 28
Slide 28 text
Weak types in JSON
What is JSON Schema?
Introduction Schema Uses DSL Conclusion
JSON Schema use
cases
Summary and further
learning
Writing a DSL with
JSON Schema
Slide 29
Slide 29 text
Writing a DSL with JSON Schema
Slide 30
Slide 30 text
Domain Specific Languages
● Computer language specialized to a particular application domain
○ In contrast to General Purpose Languages (GPLs)
Slide 31
Slide 31 text
OpenAPI / Swagger
Slide 32
Slide 32 text
Web Automation Markup Language (waml.io)
Slide 33
Slide 33 text
waml.io/editor
Slide 34
Slide 34 text
Writing a DSL with JSON Schema
"waml": {
"description": "WAML Specification semantic version number.",
"type": "string",
"pattern": "^([0-9]{1,}.[0-9]{1,}.[0-9]{1,})$",
"enum": ["0.1.0"]
}
Slide 35
Slide 35 text
Writing a DSL with JSON Schema
"steps": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/Step"
}
}
Slide 36
Slide 36 text
Writing a DSL with JSON Schema
"Step": {
"type": "object",
"description": "A step represents a single user interaction.",
"oneOf": [
{
"$ref": "#/definitions/VisitStep"
},
{
"$ref": "#/definitions/ClickStep"
}
]
}
Weak types in JSON
What is JSON Schema?
Introduction Schema Uses DSL Conclusion
JSON Schema use
cases
Summary and further
learning
Writing a DSL with
JSON Schema
Slide 40
Slide 40 text
● JSON is weakly typed
● JSON Schema
○ What is JSON Schema?
○ JSON validation with JSON Schema
○ Use cases
● Domain Specific Languages
○ What are DSLs?
○ Writing a DSL with JSON Schema
In Closing
Slide 41
Slide 41 text
No content
Slide 42
Slide 42 text
Writing Domain Specific Languages
with JSON Schema
Yos Riady
yos.io
bit.ly/2JbMTrn