Slide 1

Slide 1 text

EASY DATA MODELING WITH MSON Emmanuel Paraskakis (@manp) VP of Product, Apiary

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

OBSERVATION #1 
 APIS ARE MOSTLY DATA Apiary users spend a lot of time thinking about modeling data

Slide 5

Slide 5 text

OBSERVATION #2 
 SOFTWARE PRODUCTS ARE MOSTLY DATA In my product career, I’ve spent a lot of time modeling data

Slide 6

Slide 6 text

WHERE DO DATA MODELS COME FROM? • DBAs, Devs: SQL/ORM schemas • Architects: ER diagrams and the like • Business users: spreadsheets & documents • API devs: API definitions, JSON Schema • Front-end folks: Core Data, GraphQL schemas

Slide 7

Slide 7 text

CAN YOU SEE THE PROBLEM? 
 same needs; different languages

Slide 8

Slide 8 text

BUT THEY ALL HAVE TO AGREE ON A PRECISE DEFINITION or their needs will not be met, 
 API projects will fail

Slide 9

Slide 9 text

ALL STAKEHOLDERS NEED A COMMON LANGUAGE: • Accessible to techies and business people • Usable by machines • Broad and articulate enough to
 describe most data models • Independent of implementation
 (defer architecture decisions) • DRY - duh

Slide 10

Slide 10 text

WE HAVE A SOLUTION! 
 Markdown Syntax
 for Object Notation (MSON)

Slide 11

Slide 11 text

https://github.com/apiaryio/mson • Based on Markdown - not a `{` to be seen • Parsable, Open Source Spec • Broad enough:
 Used by Apiary users this past year (7%) • Converts to JSON Schema (we’re in the API biz) …anything else you’d like in the future! • Encourages reuse

Slide 12

Slide 12 text

A TASK - JSON { "id": "42", "title": "Buy Milk" }

Slide 13

Slide 13 text

A TASK - JSON SCHEMA { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "id": { "type": "string" }, "title": { "type": "string" } } }

Slide 14

Slide 14 text

A TASK - MSON - id: 42 - title: Buy Milk

Slide 15

Slide 15 text

MARKDOWN • id: 42 • title: Buy Milk

Slide 16

Slide 16 text

SPEC 1. Values 2. Descriptions 3. Types 4. Inheritance

Slide 17

Slide 17 text

VALUES - id: 42 - title: Buy Milk

Slide 18

Slide 18 text

DESCRIPTIONS - id: 42 - Uniquely identifies task - title: Buy Milk - Task title

Slide 19

Slide 19 text

PRIMITIVE TYPES { "id": 42, "title": "Buy Milk", "complete": false } numeric required can be null a boolean

Slide 20

Slide 20 text

PRIMITIVE TYPES { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "id": { "type": "number", "description": "Uniquely identifies task" }, "title": { "type": [ "string", "null" ], "description": "Task title" }, "complete": { "type": "boolean", "description": "Completion Status" } }, "required": [ "id" ]

Slide 21

Slide 21 text

PRIMITIVE TYPES - id: 42 (number, required) - Uniquely identifies task - title: Buy Milk (string, nullable) - Task title - complete: false (boolean) - Completion Status

Slide 22

Slide 22 text

NAMED TYPES # Task - id: 42 (number, required) - Uniquely identifies task - title: Buy Milk (string, nullable) - Task title - complete: false (boolean) - Completion Status

Slide 23

Slide 23 text

STRUCTURE TYPES - id: 84 (number, required) - Uniquely identifies project - name: Shopping List (string, nullable) - Name of project - tasks (array[Task])

Slide 24

Slide 24 text

STRUCTURE TYPES { "id": 84, "name": "Shopping List", "tasks": [ { "id": 42, "title": "Buy Milk", "complete": false } ] }

Slide 25

Slide 25 text

STRUCTURE TYPES { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "id": { "type": "number", "description": "Uniquely identifies project" }, "name": { "type": [ "string", "null" ], "description": "Name of project" }, "tasks": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "number", "description": "Uniquely identifies task" }, "title": { "type": [ "string", "null" ], "description": "Task title" }, "complete": { "type": "boolean", "description": "Completion Status" } }, "required": [ "id" ] } } }, "required": [ "id" ] }

Slide 26

Slide 26 text

INHERITANCE # User - id: 1 (number, required) - Uniquely identifies user - name: Emmanuel Paraskakis (string, required) - Name of user - email: [email protected] (string, required) - User email # TeamMember (User) - team: Shoppers (required) - Team name - role: Dairy (nullable) - Role name

Slide 27

Slide 27 text

INHERITANCE { "id": 1, "name": "Emmanuel Paraskakis", "email": "[email protected]", "team": "Shoppers", "role": "Dairy" }

Slide 28

Slide 28 text

apiary.io • Collaboration • Documentation • Prototype (Mock) • Console • →JSON • →JSON Schema • Inspector • Automated Tests

Slide 29

Slide 29 text

THANK YOU! • MSON OSS spec/parsers - please contribute! • Can be read/written by all - collaboration • Focus on getting semantics right • Format-independent • Try MSON today on apiary.io

Slide 30

Slide 30 text

apiary.io [email protected] @manp QUESTIONS?

Slide 31

Slide 31 text

FORMAT: 1A HOST: http://polls.apiblueprint.org/ # Project Management API Demo API for MSON Conference talk Basic Project Management including tasks and team members ## Tasks [/tasks] A task can have a team member assigned to it. It can also be complete or incomplete ### List all [GET] - Response 200 (application/json) - Attributes (array[Task], fixed-type) ## Task [/tasks/{id}] ### Retrieve a Task [GET] - Response 200 (application/json) - Attributes (Task) ## Projects [/projects] A project is a named collection of tasks ### List all [GET] + Response 200 (application/json) - Attributes (array[Project], fixed-type) ## Project [/projects/{id}] ### Retrieve a Project [GET] + Response 200 (application/json) - Attributes (Project) ## TeamMember [/teammembers] A Team Member inherits from a User ### List all [GET] + Response 200 (application/json) - Attributes (array[TeamMember], fixed-type) ## TeamMember [/teammembers/{id}] - Attributes (User) - team: Shoppers (required) - Team name - role: Dairy (nullable) - Role name ### Retrieve a TeamMember [GET] + Response 200 (application/json) - Attributes (TeamMember) # Data Structures ## User - id: 1 (number, required) - Uniquely identifies user - name: Emmanuel Paraskakis (string, required) - Name of user - email: [email protected] (string, required) - User email ## Task - id: 42 (number, required) - Uniquely identifies task - title: Buy Milk (string, nullable) - Task title - complete: false (boolean) - Completion Status - teamMemberId: 1 (number) - Must exist as a Team Member ## Project - id: 84 (number, required) - Uniquely identifies project - name: Shopping List (string, nullable) - Name of project - tasks (array[Task], fixed-type) SAMPLE API BLUEPRINT (67 LINES) http://docs.apistratmsondemo.apiary.io https://github.com/APIStratDemo/msonapi