SlideShare a Scribd company logo
1 of 30
Download to read offline
Proprietary + Confidential
Embracing JSON Schema
Jeremy Whitlock (@whitlockjc)
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
What is JSON Schema?
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
What is JSON Schema?
“JSON Schema is a vocabulary that allows you to
annotate and validate JSON documents.”
http://json-schema.org
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
What is JSON Schema?
“JSON Schema is a language-agnostic
description format for data structures, their
constraints and relationships.”
Jeremy Whitlock
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Simplicity Readability Language Agnostic
JSON is essentially a simple way to
represent a dict/map/… of key/value
pairs, where the values can be 1 of 6
types.
The same JSON representation is
easily consumed by humans and
machines alike.
Most languages have native support
for JSON and/or a plethora of libraries
for consuming/producing JSON.
JSON Schema
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Actual Historical Photo*
{
"message": "Ron was here!"
}
* Not really
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Description Relationships/Reuse Constraints/Validation
JSON Schema provides everything
necessary to describe data structures
regardless of their complexity.
Understanding the relationships of
more complex data structures is easy
using JSON Schema.
The same document describing your
data structures can contain
constraints that will be used by JSON
Schema libraries to do validation for
you.
JSON Schema
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema Example
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema Example
{
"title": "Submit APIStrat proposal",
"completed": true
}
TO BE CONTINUED...
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Disclaimer
All JSON Schema examples are in JSON but DO
NOT get too stuck on the JSON bit, JSON is not
required. In fact, anything that could be converted
to a JSON representation would work. For
example, YAML or a Go struct or Java Beans...
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema
{ }
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
$schema id
Used to identify the document as a
JSON Schema document, this property
value is a URL to the JSON Schema
standard your document will be using.
Used to uniquely identify your JSON
Schema document, this property value
is a URL to where your JSON Schema
document will be served. (This value
has an impact on reuse, discussed
later.)
JSON Schema - Document Metadata
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema Example
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo.json"
}
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Types
simple complex
● boolean
● integer*
● null
● number
● string
● array
● object
* Not a JSON type, specific to JSON Schema
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema Example
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo.json",
"type": "object"
}
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema Example
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo.json",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"completed": {
"type": "boolean"
}
}
}
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Validation
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo.json",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"completed": {
"type": "boolean"
}
}
}
{
"title": "Submit APIStrat proposal",
"completed": true
}
{}
{
"title": "Submit APIStrat proposal"
}
{
"title": "",
"completed": true,
"extra": [1, 2, 3]
}
[1, 2, 3]
{
"completed": "yes"
}
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Constraints and Formats
Constraints Formats
Used to apply limitations or
restrictions on the value represented in
the JSON Schema. For example,
restricting the maximum number of
characters in a string value.
Used to indicate the value is a more
specialized version of the specified
type. For example, indicating that a
string value is an email address.
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema Example
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo.json",
"type": "object",
"properties": {
"title": {
"type": "string",
"maxLength": 32
"minLength": 3
},
"completed": {
"type": "boolean"
}
},
"additionalProperties": false,
"required": ["title", "completed"]
}
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Validation
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo.json",
"type": "object",
"properties": {
"title": {
"type": "string",
"maxLength": 32
"minLength": 3
},
"completed": {
"type": "boolean"
}
},
"additionalProperties": false,
"required": ["title", "completed"]
}
{
"title": "Submit APIStrat proposal",
"completed": true
}
{}
{
"title": "Submit APIStrat proposal"
}
{
"title": "",
"completed": true,
"extra": [1, 2, 3]
}
[1, 2, 3]
{
"completed": "yes"
}
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Validation
* Not really
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Reuse
Composition Definitions References
Combining multiple separate schemas
into one, more complex schema.
There is a convention that if your
JSON Schema document has multiple
schemas in it, you nest them within a
root property named "definitions" and
use references to them.
Pointers to other schemas, whether in
the same document or in another
document, to avoid duplication.
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Definitions
The definitions property at the root
of a JSON Schema document is a
key/value pair where the key is the
human-friendly name of the schema
and the value is a schema.
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo-types.json",
"definitions": {
"Password": {
"type": "string",
// Omitted for brevity
},
"User": {
"type": "object",
// Omitted for brevity
},
"Todo": {
"type": "object",
// Omitted for brevity
}
}
}
Yes, I know comments aren't allowed in JSON...
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - References
References are a special JSON
object that has a $ref property in it
whose value is a JSON Pointer (URI)
to another location in the same file,
another file in its entirety or specific
location within another file.
{
"$schema": "http://json-schema.org/schema#",
"id": "http://example.com/schemas/todo-items.json",
"definitions": {
"Todo": {
"type": "object",
"properties": {
"owner": {
"$ref": "person.json"
},
"created": {
"$ref": "types.json#/definitions/Timestamp"
},
// Omitted for brevity
}
},
}
"type": "array",
"items": {
"$ref": "#/definitions/Todo
},
// Omitted for brevity
}
Yes, I know comments aren't allowed in JSON...
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Composition
allOf ● An array of schemas
● The data must validate against all schemas
anyOf ● An array of schemas
● The data must validate against at least one schema
oneOf ● An array of schemas
● The data must validate against only one schema
not* ● A subschema
● The data must not validate against the subschema
* not is not really a composition property but it's typically documented alongside the others
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
JSON Schema - Miscellaneous
Schema Metadata Default Values
The title and description properties
can be used on any schema to give it a
human readable name and description
of what the schema represents.
Sometimes your data structures have
optional values and using a default
property allows you to fill in the gaps
when the values are not provided
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Using JSON Schema
● Code generation
● Contract enforcement
● Documentation generation
● Interface design
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Using JSON Schema - OpenAPI
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
Using JSON Schema - Resources
JSON Homepage/Reference - http://www.json.org/
JSON Schema Tooling - http://json-schema.org/implementations.html
JSON Schema Homepage - http://json-schema.org/
Understanding JSON Schema Book - https://spacetelescope.github.io/understanding-json-schema/
JSON Schema Online Editor - https://jsonschema.net/#/editor
Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem
The End
No...I'm not really signing autographs. They wouldn't be worth the paper they are written on. ;)

More Related Content

What's hot

Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheetssmitha273566
 
Javascript inside Browser (DOM)
Javascript inside Browser (DOM)Javascript inside Browser (DOM)
Javascript inside Browser (DOM)Vlad Mysla
 
XML's validation - XML Schema
XML's validation - XML SchemaXML's validation - XML Schema
XML's validation - XML Schemavidede_group
 
XML Schema
XML SchemaXML Schema
XML SchemaKumar
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schemagauravashq
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLToni Kolev
 
The Document Object Model
The Document Object ModelThe Document Object Model
The Document Object ModelKhou Suylong
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptMarc Huang
 

What's hot (20)

Xsd
XsdXsd
Xsd
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Xml schema
Xml schemaXml schema
Xml schema
 
Javascript inside Browser (DOM)
Javascript inside Browser (DOM)Javascript inside Browser (DOM)
Javascript inside Browser (DOM)
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
 
Xml Lecture Notes
Xml Lecture NotesXml Lecture Notes
Xml Lecture Notes
 
Xml p5 Lecture Notes
Xml p5 Lecture NotesXml p5 Lecture Notes
Xml p5 Lecture Notes
 
Xsd tutorial
Xsd tutorialXsd tutorial
Xsd tutorial
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
 
XML's validation - XML Schema
XML's validation - XML SchemaXML's validation - XML Schema
XML's validation - XML Schema
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Html (1)
Html (1)Html (1)
Html (1)
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTML
 
The Document Object Model
The Document Object ModelThe Document Object Model
The Document Object Model
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Markup Languages
Markup Languages Markup Languages
Markup Languages
 
Xml schema
Xml schemaXml schema
Xml schema
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
 

Similar to LF_APIStrat17_Embracing JSON Schema

Similar to LF_APIStrat17_Embracing JSON Schema (20)

Advanced Json
Advanced JsonAdvanced Json
Advanced Json
 
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
 
Hands on JSON
Hands on JSONHands on JSON
Hands on JSON
 
JSON-LD: JSON for the Social Web
JSON-LD: JSON for the Social WebJSON-LD: JSON for the Social Web
JSON-LD: JSON for the Social Web
 
JSON and JSON Schema in Oxygen
JSON and JSON Schema in OxygenJSON and JSON Schema in Oxygen
JSON and JSON Schema in Oxygen
 
json
jsonjson
json
 
Json tutorial, a beguiner guide
Json tutorial, a beguiner guideJson tutorial, a beguiner guide
Json tutorial, a beguiner guide
 
Json
JsonJson
Json
 
J s-o-n-120219575328402-3
J s-o-n-120219575328402-3J s-o-n-120219575328402-3
J s-o-n-120219575328402-3
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
Json
JsonJson
Json
 
Json at work overview and ecosystem-v2.0
Json at work   overview and ecosystem-v2.0Json at work   overview and ecosystem-v2.0
Json at work overview and ecosystem-v2.0
 
Basics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examplesBasics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examples
 
Json
JsonJson
Json
 
Json
JsonJson
Json
 
The JSON REST API for WordPress
The JSON REST API for WordPressThe JSON REST API for WordPress
The JSON REST API for WordPress
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
 
Json
JsonJson
Json
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"
 
AMS, API, RAILS and a developer, a Love Story
AMS, API, RAILS and a developer, a Love StoryAMS, API, RAILS and a developer, a Love Story
AMS, API, RAILS and a developer, a Love Story
 

More from LF_APIStrat

LF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API UnderprotectionLF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API UnderprotectionLF_APIStrat
 
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...LF_APIStrat
 
LF_APIStrat17_Super-Powered REST API Testing
LF_APIStrat17_Super-Powered REST API TestingLF_APIStrat17_Super-Powered REST API Testing
LF_APIStrat17_Super-Powered REST API TestingLF_APIStrat
 
LF_APIStrat17_How Mature are You? A Developer Experience Maturity Model
LF_APIStrat17_How Mature are You? A Developer Experience Maturity ModelLF_APIStrat17_How Mature are You? A Developer Experience Maturity Model
LF_APIStrat17_How Mature are You? A Developer Experience Maturity ModelLF_APIStrat
 
LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...
LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...
LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...LF_APIStrat
 
LF_APIStrat17_Things I Wish People Told Me About Writing Docs
LF_APIStrat17_Things I Wish People Told Me About Writing DocsLF_APIStrat17_Things I Wish People Told Me About Writing Docs
LF_APIStrat17_Things I Wish People Told Me About Writing DocsLF_APIStrat
 
LF_APIStrat17_Lifting Legacy to the Cloud on API Boosters
LF_APIStrat17_Lifting Legacy to the Cloud on API BoostersLF_APIStrat17_Lifting Legacy to the Cloud on API Boosters
LF_APIStrat17_Lifting Legacy to the Cloud on API BoostersLF_APIStrat
 
LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...
LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...
LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...LF_APIStrat
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat
 
LF_APIStrat17_How We Doubled the Velocity of Our Developer Experience Team
LF_APIStrat17_How We Doubled the Velocity of Our Developer Experience TeamLF_APIStrat17_How We Doubled the Velocity of Our Developer Experience Team
LF_APIStrat17_How We Doubled the Velocity of Our Developer Experience TeamLF_APIStrat
 
LF_APIStrat17_API Marketing: First Comes Usability, then Discoverability
LF_APIStrat17_API Marketing: First Comes Usability, then DiscoverabilityLF_APIStrat17_API Marketing: First Comes Usability, then Discoverability
LF_APIStrat17_API Marketing: First Comes Usability, then DiscoverabilityLF_APIStrat
 
LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...
LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...
LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...LF_APIStrat
 
LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions LF_APIStrat
 
LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...
LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...
LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...LF_APIStrat
 
LF_APIStrat17_Case Study: Cold Decision Trees
LF_APIStrat17_Case Study: Cold Decision TreesLF_APIStrat17_Case Study: Cold Decision Trees
LF_APIStrat17_Case Study: Cold Decision TreesLF_APIStrat
 
LF_APIStrat17_Getting Your API House In Order
LF_APIStrat17_Getting Your API House In OrderLF_APIStrat17_Getting Your API House In Order
LF_APIStrat17_Getting Your API House In OrderLF_APIStrat
 
LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...
LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...
LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...LF_APIStrat
 
LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...
LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...
LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...LF_APIStrat
 
LF_APIStrat17_Open Data vs. the World
LF_APIStrat17_Open Data vs. the World LF_APIStrat17_Open Data vs. the World
LF_APIStrat17_Open Data vs. the World LF_APIStrat
 
LF_APIStrat17_Practical DevSecOps for APIs
LF_APIStrat17_Practical DevSecOps for APIsLF_APIStrat17_Practical DevSecOps for APIs
LF_APIStrat17_Practical DevSecOps for APIsLF_APIStrat
 

More from LF_APIStrat (20)

LF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API UnderprotectionLF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API Underprotection
 
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
 
LF_APIStrat17_Super-Powered REST API Testing
LF_APIStrat17_Super-Powered REST API TestingLF_APIStrat17_Super-Powered REST API Testing
LF_APIStrat17_Super-Powered REST API Testing
 
LF_APIStrat17_How Mature are You? A Developer Experience Maturity Model
LF_APIStrat17_How Mature are You? A Developer Experience Maturity ModelLF_APIStrat17_How Mature are You? A Developer Experience Maturity Model
LF_APIStrat17_How Mature are You? A Developer Experience Maturity Model
 
LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...
LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...
LF_APIStrat17_Connect Your RESTful API to Hundreds of Others in Minutes (Zapi...
 
LF_APIStrat17_Things I Wish People Told Me About Writing Docs
LF_APIStrat17_Things I Wish People Told Me About Writing DocsLF_APIStrat17_Things I Wish People Told Me About Writing Docs
LF_APIStrat17_Things I Wish People Told Me About Writing Docs
 
LF_APIStrat17_Lifting Legacy to the Cloud on API Boosters
LF_APIStrat17_Lifting Legacy to the Cloud on API BoostersLF_APIStrat17_Lifting Legacy to the Cloud on API Boosters
LF_APIStrat17_Lifting Legacy to the Cloud on API Boosters
 
LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...
LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...
LF_APIStrat17_Contract-first API Development: A Case Study in Parallel API Pu...
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
 
LF_APIStrat17_How We Doubled the Velocity of Our Developer Experience Team
LF_APIStrat17_How We Doubled the Velocity of Our Developer Experience TeamLF_APIStrat17_How We Doubled the Velocity of Our Developer Experience Team
LF_APIStrat17_How We Doubled the Velocity of Our Developer Experience Team
 
LF_APIStrat17_API Marketing: First Comes Usability, then Discoverability
LF_APIStrat17_API Marketing: First Comes Usability, then DiscoverabilityLF_APIStrat17_API Marketing: First Comes Usability, then Discoverability
LF_APIStrat17_API Marketing: First Comes Usability, then Discoverability
 
LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...
LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...
LF_APIStrat17_Standing Taller with Technology: APIs, IoT, and the Digital Wor...
 
LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions
 
LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...
LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...
LF_APIStrat17_I Believe You But My Enterprise Don't: Adopting Open Standards ...
 
LF_APIStrat17_Case Study: Cold Decision Trees
LF_APIStrat17_Case Study: Cold Decision TreesLF_APIStrat17_Case Study: Cold Decision Trees
LF_APIStrat17_Case Study: Cold Decision Trees
 
LF_APIStrat17_Getting Your API House In Order
LF_APIStrat17_Getting Your API House In OrderLF_APIStrat17_Getting Your API House In Order
LF_APIStrat17_Getting Your API House In Order
 
LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...
LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...
LF_APIStrat17_Diving Deep into the API Ocean with Open Source Deep Learning T...
 
LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...
LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...
LF_APIStrat17_Supporting SDKs in 7 Different Programming Languages While Main...
 
LF_APIStrat17_Open Data vs. the World
LF_APIStrat17_Open Data vs. the World LF_APIStrat17_Open Data vs. the World
LF_APIStrat17_Open Data vs. the World
 
LF_APIStrat17_Practical DevSecOps for APIs
LF_APIStrat17_Practical DevSecOps for APIsLF_APIStrat17_Practical DevSecOps for APIs
LF_APIStrat17_Practical DevSecOps for APIs
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

LF_APIStrat17_Embracing JSON Schema

  • 1. Proprietary + Confidential Embracing JSON Schema Jeremy Whitlock (@whitlockjc)
  • 2. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem What is JSON Schema?
  • 3. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem What is JSON Schema? “JSON Schema is a vocabulary that allows you to annotate and validate JSON documents.” http://json-schema.org
  • 4. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem What is JSON Schema? “JSON Schema is a language-agnostic description format for data structures, their constraints and relationships.” Jeremy Whitlock
  • 5. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Simplicity Readability Language Agnostic JSON is essentially a simple way to represent a dict/map/… of key/value pairs, where the values can be 1 of 6 types. The same JSON representation is easily consumed by humans and machines alike. Most languages have native support for JSON and/or a plethora of libraries for consuming/producing JSON. JSON Schema
  • 6. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Actual Historical Photo* { "message": "Ron was here!" } * Not really
  • 7. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Description Relationships/Reuse Constraints/Validation JSON Schema provides everything necessary to describe data structures regardless of their complexity. Understanding the relationships of more complex data structures is easy using JSON Schema. The same document describing your data structures can contain constraints that will be used by JSON Schema libraries to do validation for you. JSON Schema
  • 8. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema Example
  • 9. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema Example { "title": "Submit APIStrat proposal", "completed": true } TO BE CONTINUED...
  • 10. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Disclaimer All JSON Schema examples are in JSON but DO NOT get too stuck on the JSON bit, JSON is not required. In fact, anything that could be converted to a JSON representation would work. For example, YAML or a Go struct or Java Beans...
  • 11. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema { }
  • 12. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem $schema id Used to identify the document as a JSON Schema document, this property value is a URL to the JSON Schema standard your document will be using. Used to uniquely identify your JSON Schema document, this property value is a URL to where your JSON Schema document will be served. (This value has an impact on reuse, discussed later.) JSON Schema - Document Metadata
  • 13. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema Example { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo.json" }
  • 14. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Types simple complex ● boolean ● integer* ● null ● number ● string ● array ● object * Not a JSON type, specific to JSON Schema
  • 15. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema Example { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo.json", "type": "object" }
  • 16. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema Example { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo.json", "type": "object", "properties": { "title": { "type": "string" }, "completed": { "type": "boolean" } } }
  • 17. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Validation { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo.json", "type": "object", "properties": { "title": { "type": "string" }, "completed": { "type": "boolean" } } } { "title": "Submit APIStrat proposal", "completed": true } {} { "title": "Submit APIStrat proposal" } { "title": "", "completed": true, "extra": [1, 2, 3] } [1, 2, 3] { "completed": "yes" }
  • 18. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Constraints and Formats Constraints Formats Used to apply limitations or restrictions on the value represented in the JSON Schema. For example, restricting the maximum number of characters in a string value. Used to indicate the value is a more specialized version of the specified type. For example, indicating that a string value is an email address.
  • 19. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema Example { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo.json", "type": "object", "properties": { "title": { "type": "string", "maxLength": 32 "minLength": 3 }, "completed": { "type": "boolean" } }, "additionalProperties": false, "required": ["title", "completed"] }
  • 20. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Validation { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo.json", "type": "object", "properties": { "title": { "type": "string", "maxLength": 32 "minLength": 3 }, "completed": { "type": "boolean" } }, "additionalProperties": false, "required": ["title", "completed"] } { "title": "Submit APIStrat proposal", "completed": true } {} { "title": "Submit APIStrat proposal" } { "title": "", "completed": true, "extra": [1, 2, 3] } [1, 2, 3] { "completed": "yes" }
  • 21. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Validation * Not really
  • 22. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Reuse Composition Definitions References Combining multiple separate schemas into one, more complex schema. There is a convention that if your JSON Schema document has multiple schemas in it, you nest them within a root property named "definitions" and use references to them. Pointers to other schemas, whether in the same document or in another document, to avoid duplication.
  • 23. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Definitions The definitions property at the root of a JSON Schema document is a key/value pair where the key is the human-friendly name of the schema and the value is a schema. { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo-types.json", "definitions": { "Password": { "type": "string", // Omitted for brevity }, "User": { "type": "object", // Omitted for brevity }, "Todo": { "type": "object", // Omitted for brevity } } } Yes, I know comments aren't allowed in JSON...
  • 24. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - References References are a special JSON object that has a $ref property in it whose value is a JSON Pointer (URI) to another location in the same file, another file in its entirety or specific location within another file. { "$schema": "http://json-schema.org/schema#", "id": "http://example.com/schemas/todo-items.json", "definitions": { "Todo": { "type": "object", "properties": { "owner": { "$ref": "person.json" }, "created": { "$ref": "types.json#/definitions/Timestamp" }, // Omitted for brevity } }, } "type": "array", "items": { "$ref": "#/definitions/Todo }, // Omitted for brevity } Yes, I know comments aren't allowed in JSON...
  • 25. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Composition allOf ● An array of schemas ● The data must validate against all schemas anyOf ● An array of schemas ● The data must validate against at least one schema oneOf ● An array of schemas ● The data must validate against only one schema not* ● A subschema ● The data must not validate against the subschema * not is not really a composition property but it's typically documented alongside the others
  • 26. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem JSON Schema - Miscellaneous Schema Metadata Default Values The title and description properties can be used on any schema to give it a human readable name and description of what the schema represents. Sometimes your data structures have optional values and using a default property allows you to fill in the gaps when the values are not provided
  • 27. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Using JSON Schema ● Code generation ● Contract enforcement ● Documentation generation ● Interface design
  • 28. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Using JSON Schema - OpenAPI
  • 29. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem Using JSON Schema - Resources JSON Homepage/Reference - http://www.json.org/ JSON Schema Tooling - http://json-schema.org/implementations.html JSON Schema Homepage - http://json-schema.org/ Understanding JSON Schema Book - https://spacetelescope.github.io/understanding-json-schema/ JSON Schema Online Editor - https://jsonschema.net/#/editor
  • 30. Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem The End No...I'm not really signing autographs. They wouldn't be worth the paper they are written on. ;)