• Stars
    star
    899
  • Rank 50,793 (Top 2 %)
  • Language
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Markdown Syntax for Object Notation

Markdown Syntax for Object Notation

This document provides an introduction to Markdown Syntax for Object Notation (MSON), a Markdown syntax compatible with describing JSON and JSON Schema.

What?

MSON is a plain-text, human and machine readable, description format for describing data structures in common markup formats such as JSON, XML or YAML.

What for?

The aim of this description format is to facilitate the discussion (and thus validation) of data structures. The format, being agnostic to the common markup formats, is well suited for "resource & representations" and "content negotiation" scenarios.

In addition, this format also offers (limited) serialization functionality.

Similar to the original Markdown to HTML (markup) conversion, MSON enables conversion to other markup formats.

Who & Why?

This format is being developed by Apiary as a part of the API Blueprint syntax to provide a means for description and validation of HTTP payloads and DRY, media-type agnostic, resource descriptions and to simplify content-negotiation.

NOTE: While this document focuses primarily on JSON and JSON Schema examples, the underlying specification will ultimately allow producing XML or YAML representations from MSON.

Notational Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC2119.

Example 1

A simple object structure and its associated JSON expression.

MSON

- id: 1
- name: A green door
- price: 12.50
- tags: home, green

Rendered Markdown

  • id: 1
  • name: A green door
  • price: 12.50
  • tags: home, green

JSON

{
    "id": "1",
    "name": "A green door",
    "price": "12.50",
    "tags": [ "home", "green" ]
}

NOTE: By default, a Markdown list item is considered to be a string type.


Example 2

A Named Type with its associated JSON expression and JSON Schema.

MSON

# Product
A product from Acme's catalog

## Properties

- id: 1 (number, required) - The unique identifier for a product
- name: A green door (string, required) - Name of the product
- price: 12.50 (number, required)
- tags: home, green (array[string])

Rendered Markdown

Product

A product from Acme's catalog

Properties
  • id: 1 (number, required) - The unique identifier for a product
  • name: A green door (string, required) - Name of the product
  • price: 12.50 (number, required)
  • tags: home, green (array[string], fixed-type)

JSON

{
    "id": 1,
    "name": "A green door",
    "price": 12.50,
    "tags": [ "home", "green" ]
}

NOTE: The id and price sample values are numbers given the explicit declaration of their base type of number vs. the default of string as in Example 1.

JSON Schema

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Product",
    "description": "A product from Acme's catalog",
    "type": "object",
    "properties": {
        "id": {
            "description": "The unique identifier for a product",
            "type": "number"
        },
        "name": {
            "description": "Name of the product",
            "type": "string"
        },
        "price": {
            "type": "number"
        },
        "tags": {
            "type": "array",
            "items": {
                "type": "string"
            }
        }
    },
    "required": ["id", "name", "price"]
}

NOTE: This proposal covers only basic features of JSON Schema. At this moment, it is out of the scope of this syntax to support all the JSON Schema keywords (such as uniqueItems, exclusiveMinimum, etc.).


MSON Language Specification

The rest of this document covers some advanced syntax examples. Refer to the MSON Language Specification for the complete MSON Grammar Reference.

Quick Links

Objects & Arrays

By default, a Markdown list item with a nested Markdown list is considered to be an object structure:

MSON

- address
    - street
    - city
    - state

JSON

{
    "address" : {
        "street": "",
        "city": "",
        "state": ""
    }
}

If a Markdown list's items are intended to be literals (represent array values), the type of the parent list item MUST be explicitly set to array:

MSON

- address (array)
    - street
    - city
    - state

Or, alternately:

- address: street, city, state (array)

In this latter case, using a comma-separated list of values, the type (array) is implied and thus MAY be omitted.

JSON

{
    "address": [ "street", "city", "state" ]
}

NOTE: The values "street", "city", and "state" are solely sample values of the address array in this example. No constraints are implied on the quantity or types of values in such an array other than that they MAY be string literals.

Advanced Objects

Non-uniform Property

A Property whose value can be of different types is defined by the enum structure type:

MSON

- tag (enum)
    - green (string)
    - (object)
        - tag_id: 1
        - label: green

Rendered Markdown

  • tag (enum)
    • green (string)
    • (object)
      • tag_id: 1
      • label: green

JSON

{
    "tag": "green"
}

or

{
    "tag": {
        "tag_id": "1",
        "label": "green"
    }
}

NOTE: In an enum structure, in contrast to an array type structure, a value like "green" is a fully-qualified value of the enumeration vs. being a sample value.


Mutually Exclusive Properties

By default, all properties are optional and may or may not be included in the object. If there is a choice of mutually exclusive properties available MSON defines a One Of type:

MSON

- city
- One Of
    - state
    - province
- country

Rendered Markdown

  • city
  • One Of
    • province
    • state
  • country

JSON

{
    "street": "",
    "province": "",
    "country": ""
}

or

{
    "street": "",
    "state": "",
    "country": ""
}

NOTE: Because an enum type MUST define a list of types vs. properties and by default an un-nested Markdown list defines properties of an implied object structure, the One Of type declaration MUST only be used to indicate mutually exclusive properties in an object structure.


Advanced Arrays

Array of Mixed Types

MSON

- tags (array)
    - hello (string)
    - 42 (number)

Rendered Markdown

  • tags (array)
    • hello (string)
    • 42 (number)

JSON

{
    "tags": [ "hello", 42 ]
}

MSON

- (array)
    - (object)
        - name: snow (string)
        - description (string)
    - 42 (number)

Rendered Markdown

  • (array)
    • (object)
      • name: snow (string)
      • description (string)
    • 42 (number)

JSON

[
    {
        "name": "snow",
        "description": ""
    },
    42
]

Array of Arrays

MSON

- (array)
    - 1, 2, 3, 4 (array[number])

Rendered Markdown

  • (array)
    • 1, 2, 3, 4 (array[number])

JSON

[
    [ 1, 2, 3, 4 ]
]

Multi-line Descriptions

In the case where a one-liner description is not sufficient, a multi-paragraph text block is the way to go.

MSON

- id: 1 (number, required) - The unique identifier for a product
- name: A green door (string, required)

    Lorem ipsum dolor sit amet, consectetur adipiscing elit.

    Sed sed lacus a arcu vehicula ultricies sed vel nibh. Mauris id cursus felis.

    Interdum et malesuada fames ac ante ipsum primis in faucibus.

    - unus
    - duo
    - tres
    - quattuor

- price: 12.50 (number, required)
- tags: home, green (array)

For a multi-line description of a structure type, an Items, Members , or Properties keyword MUST be used to avoid conflict with potential list item values that are part of the description:

- tags (array)

    Lorem ipsum dolor sit amet, consectetur adipiscing elit.

    Sed sed lacus a arcu vehicula ultricies sed vel nibh. Mauris id cursus felis.

    Interdum et malesuada fames ac ante ipsum primis in faucibus.

    - unus
    - duo
    - tres
    - quattuor

    - Items
        - home
        - green

NOTE: Unus ... quattuor are considered part of the text block vs. defining items of the array.

Escaping

Markdown code span element syntax (` `) is used to escape reserved Keywords that should just be interpretted as literals as well as other constructs that may be erroneously interpreted by an MSON parser as meaningful.

For non-Keywords, a code span can be used for formatting Markdown as an aesthetic preference.

MSON

- listing (object)

    Our real estate listing has different properties available.

    - `Properties`
        - This one.
        - That one.

    - Properties
        - description (string)
        - date_listed (string)
        - `some:location`: local (string)

Rendered Markdown

  • listing (object)

    Our real estate listing has different properties available.

    • Properties

      • This one.
      • That one.
    • Properties

      • description
      • date_listed
      • some:location: local (string)

NOTE: In this example, the first "Properties" string is part of the multi-line block description whereas the second defines the properties of the listing object.


Variable Property Name

Variable property name (key) is defined using italics. Note that a variable property cannot be required.

MSON

- _links
    - *self*
        - href: a URI

Rendered Markdown

  • _links
    • self
      • href: a URI

JSON

{
    "_links": {
        "self": {
            "href": "..."
        },
        "users": {
            "href": "..."
        }
    }
}

Type Definition

Additional Named Types can be defined using a Markdown header:

MSON

# Address (object)
Description is here! Properties to follow.

## Properties
- street
- state
- zip

The same entity defined as an address property:

- address (object)

    Description is here! Properties to follow.

    - Properties
        - street
        - state
        - zip

The same address property referencing the previously Named type:

- address (Address)

Referencing

Anywhere a type is expected, a top-level MSON Named Type can be referenced.

MSON

# Address (object)
- street
- city
- state
- zip

# User (object)
- first_name
- last_name
- address (Address)

Rendered Markdown

Address (object)
  • street
  • city
  • state
  • zip
User (object)
  • first_name
  • last_name
  • address (Address)

JSON

{
    "first_name": "",
    "last_name": "",
    "address": {
        "street": "",
        "city": "",
        "state": "",
        "zip": ""
    }
}

Mixins

To include (mixin) values or properties in another Named Type use the Include keyword followed by a reference to the
MSON Named Type.

MSON

# Address Object
- street
- city
- state
- zip

# User Object
- first_name
- last_name
- Include Address

Rendered Markdown

Address Object
  • street
  • city
  • state
  • zip
User Object
  • first_name
  • last_name
  • Include Address

JSON

{
    "first_name": "",
    "last_name": "",
    "street": "",
    "city": "",
    "state": "",
    "zip": ""
}

NOTE: A mixin can only use a Named Type that is derived from the same type of structure including the mixin. Further, the parent structure inherits all the members of the included Named Type and maintains the order the members were originally defined.

More Repositories

1

api-blueprint

API Blueprint
8,638
star
2

dredd

Language-agnostic HTTP API Testing Tool
JavaScript
4,169
star
3

snowcrash

API Blueprint Parser
C++
373
star
4

protagonist

Protagonist is Node.js wrapper for the API Blueprint parser
C++
349
star
5

drafter

API Blueprint Parser (C++)
C++
301
star
6

apiary-client

Apiary CLI client
Ruby
203
star
7

curl-trace-parser

Parser for output from Curl --trace option
JavaScript
198
star
8

api-blueprint-sublime-plugin

API Blueprint Sublime Text plugin
Python
176
star
9

s3-streaming-upload

s3-streaming-upload is node.js library that listens to your stream and upload its data to Amazon S3 using ManagedUpload API.
JavaScript
123
star
10

gavel-spec

Behavior specification for Gavel, validator of HTTP transactions
Gherkin
105
star
11

swagger2blueprint

Convert Swagger API descriptions into API Blueprint
JavaScript
99
star
12

gavel.js

Validator of HTTP messages (JavaScript implementation)
JavaScript
97
star
13

dredd-example

Example application using Dredd and CI
JavaScript
85
star
14

api-elements.js

Library for consuming API Elements in JavaScript
JavaScript
74
star
15

redsnow

Ruby binding for the Snow Crash library, also a thermonuclear weapon.
Ruby
69
star
16

drafter.js

API Blueprint parser in JS
JavaScript
55
star
17

fury.js

API Description SDK
JavaScript
52
star
18

emscripten-docker

Emscripten as docker images
Dockerfile
51
star
19

cloudwatch-to-papertrail

Lambda to send logs from Cloudwatch to Papertrail
JavaScript
48
star
20

blueprint-parser

Deprecated PEG.js-based parser for parsing legacy Apiary Blueprint Format
CoffeeScript
47
star
21

polls-api

Polls is an example web API that allows consumers to view polls and vote in them.
Python
46
star
22

api-blueprint-rfcs

The API Blueprint RFC process
44
star
23

chrome-extension-ci

How to put a Chrome Extension into CI
JavaScript
41
star
24

attributes-kit

DEPRECATED Attributes Kit helps you with rendering MSON.
JavaScript
39
star
25

drafter-npm

Node API Blueprint Parser
JavaScript
37
star
26

language-templates

Language templates used to render example HTTP calls in different languages
HTML
36
star
27

polls-app

Swift iPhone and iPad Client for Polls API, using Hyperdrive API client
Swift
34
star
28

heroku-datadog-drain-golang

Funnel metrics from multiple Heroku apps into DataDog using statsd.
Go
34
star
29

api-blueprint-ast

API Blueprint AST Serialization Media Types [adhd, apib]
32
star
30

Paw-APIBlueprintGenerator

Paw extension providing support to export API Blueprint as a code generator.
CoffeeScript
32
star
31

api-elements

API Elements is a structure for describing APIs and the complex data structures used within them.
Python
28
star
32

http-string-parser

Parse HTTP Request and Response from String in Node.JS
CoffeeScript
26
star
33

apiblueprint.org

API Blueprint Website
CSS
19
star
34

apiblueprintorg

old apiblueprint.org site
CoffeeScript
19
star
35

dredd-hooks-python

Python Hooks for Dredd API Testing Framework
Python
19
star
36

matter_compiler

API Blueprint AST to API Blueprint Conversion Tool [adhd]
Ruby
16
star
37

api-blueprint-cheatsheet

API Blueprint Cheatsheet
API Blueprint
16
star
38

apiaryio.github.com

Apiary Blog
HTML
16
star
39

dredd-hooks-ruby

Ruby Hooks Worker for Dredd API Testing Framework
Ruby
15
star
40

fury-cli

Command line tool interface for Fury.js
JavaScript
12
star
41

fury-adapter-swagger

Swagger 2.0 parser adapter for Fury.js
JavaScript
11
star
42

dredd-transactions

Compiles a list of HTTP transactions (request-response pairs) from an API description document
JavaScript
10
star
43

markdown-parser

The real Markdown parser deal. You know, the one with a Markdown AST. Based on Upskirt, Sundown, Redcarpet or Hoedown whatever is trending.
C++
10
star
44

ivy

A Node.js queue library focused on easy, yet flexible task execution.
CoffeeScript
9
star
45

Paw-APIBlueprintImporter

Paw extension to import API Blueprint
JavaScript
8
star
46

sos

Simple c++ Object Serialization
C++
8
star
47

api.apiblueprint.org

API Blueprint
7
star
48

docker-base-images

Base docker images for Apiary applications
Dockerfile
7
star
49

constitutions

Write API Style Guide Rules locally, collaboratively and test them in CI
JavaScript
6
star
50

deckardcain

Deckard Cain library identifies (media) type of API description files
JavaScript
6
star
51

boutique.js

The finest representations to emphasize natural beauty of your MSON AST
CoffeeScript
6
star
52

protected-s3

Simple application that allows you to display the content of your S3 to authorised users only.
JavaScript
6
star
53

black-belt

Internal toolbelt on steroids (idle since September 2018)
Python
6
star
54

mson-ast

MSON AST Serialization Media Types
4
star
55

dredd-hooks-template

Template of an integration test suite for writing Dredd hooks handler in a new language
JavaScript
4
star
56

dredd-docker

Docker image for Dredd, a language-agnostic HTTP API testing tool
Shell
4
star
57

mson-zoo

Collection of MSON samples that can be used as a showcase or testing purposes
JavaScript
4
star
58

base-styles

Apiary Base CSS Styles
CSS
3
star
59

fury-adapter-apib-serializer

API Blueprint serializer for Fury.js
JavaScript
3
star
60

dredd-test-rails

Example Rails application for testing with API Blueprint and Dredd
Ruby
3
star
61

npm-boilerplate

Boilerplate for NPM package with Mocha, CoffeeScript and test directory structure
Shell
3
star
62

swagger-zoo

A collection of Swagger examples and their Refract representation
JavaScript
2
star
63

heroku-kafka-demo-nodejs

HTML
2
star
64

blueprint-transactions

Deprecated compiler of HTTP Transactions from API Blueprint AST
CoffeeScript
2
star
65

refract-query

JavaScript
2
star
66

generator-apiary-lib

Deprecated Apiary's Yeoman generator for basic library scaffolding
JavaScript
2
star
67

datapool

Library of miscellaneous reusable data models for API Blueprint
2
star
68

apiary_blueprint_convertor

Legacy Apiary Blueprint AST to API Blueprint AST convertor.
Ruby
1
star
69

metamorphoses

Transforms API Blueprint AST or legacy Apiary Blueprint AST into Apiary Application AST
CoffeeScript
1
star
70

wercker-npm-install-test

Dockerfile
1
star
71

pagerduty-overlap-checker

Pager Duty Overrides Checker
JavaScript
1
star
72

tully-test

API Blueprint
1
star
73

api-blueprint-http-formatter

Format pair of HTTP Request and Response to API Blueprint format
CoffeeScript
1
star
74

abagnale

Forge unique IDs for Refract data structure elements
JavaScript
1
star
75

blueprint-markdown-renderer

Default parser and set of settings for parsing Markdown blocks in API Blueprint
JavaScript
1
star
76

misterio

Testing project to compare C++ parser generator for ability to parse blueprint
C++
1
star
77

dribbble-api

API Blueprint
1
star
78

example-intersphinx-repo

This repository demonstrates using Intersphinx with indexes being exported in Docker volume
Python
1
star
79

console-proxy

Apiary Browser Console
JavaScript
1
star