This document defines serialization formats for MSON abstract syntax tree. For the definition of MSON AST Source Map see the MSON AST Source Map definition.
As of 2015-08-10 the AST is deprecated and should not be used for new development. The MSON AST has been superseded by Data Structure Refract Namespace. The Data Structure Refract Namespace will be offered by API Blueprint parser harness – Drafter.
If you are relying on MSON AST please contact @zdne as soon as possible.
Following is the definition of MSON AST serializations data structures using the MSON syntax.
NOTE: Refer to the MSON Specification for the explanation of terms used throughout this document.
Top-level MSON document or block.
types
(array[Named Type]) - List of top-level Named Types described in the documentUser-defined named type.
name
(Type Name) - Name of the type being definedtypeDefinition
(Type Definition) - The ancestor type definitionsections
(array[Type Section]) - Ordered list of type sectionsBase or named type's name.
boolean
(string)string
(string)number
(string)array
(string)enum
(string)object
(string)Type symbol (identifier).
literal
(Literal) - Name of the symbolvariable
: false
(boolean, default) - Boolean flag to denote Variable Type Name, true
for variable type name, false
otherwiseDefinition of an instance value type.
typeSpecification
(object)
attributes
(array) - List of attributes associated with the type
required
optional
default
sample
fixed
Section of a type. The section can be any of the Type Sections as described in the MSON Specification.
class
(enum[string]) - Denotes the class of the type section
blockDescription
- Section is a markdown block descriptionmemberType
- Section holds member type(s) elementssample
- Section defines alternate value(s) for member typesdefault
- Section defines the default value(s) for member typesvalidation
- Reserved for future usecontent
(enum) - Content of the section based on its class
An element of a type section. The element holds either a member type (value
or property
), Mixin type, One Of type or groups elements in a collection of Elements.
class
(enum[string]) - Class of the member object
property
- Property member typevalue
- Value member typemixin
- Mixin typeoneOf
- One Of typegroup
- Group of other elementscontent
(enum)
property
)value
)mixin
)oneOf
)group
)Collection of elements.
Individual member of an object
type structure.
name
(Property Name) - Name of the object propertyName of a property member.
literal
(Literal) - Literal name of the propertyvariable
(Value Definition) - Variable name of the propertyIndividual member of an array
or enum
type structure.
description
(Markdown) - Inline description of the member typevalueDefinition
(Value Definition) - The definition of the member's valuesections
(array[Type Section]) - List of member's type sectionsMixin type.
One Of type. List of mutually exclusive elements.
Note the only allowed Element classes are are property
, mixin
, oneOf
and group
.
Value definition of a type instance.
values
(array[Value]) - List of values specified in the definitiontypeDefinition
(Type Definition) - Type of the valueSample or actual value of a type instance
literal
(Literal) - The literal valuevariable
: false
(boolean, default) - true
to denote variable value, false
otherwiseMarkdown formatted plain text string.
Literal value in the form of a plain-text.
The base type media type is application/vnd.mson.ast
.
Two supported, feature-equal, serialization formats are JSON and YAML:
application/vnd.mson.ast+json
application/vnd.mson.ast+yaml
Given the following MSON
- id: 1 (required)
- name: A green door
- price: 12.50 (number)
- tags: home, green
- vector (array)
- 1
- 2
- 3
application/vnd.mson.ast+json; version=2.0
{
"types": [
{
"name": null,
"typeDefinition": {
"typeSpecification": {
"name": "object"
}
},
"sections": [
{
"class": "memberType",
"content": [
{
"class": "property",
"content": {
"name": {
"literal": "id"
},
"valueDefinition": {
"values": [
{
"literal": "1"
}
],
"typeDefinition": {
"attributes": [
"required"
]
}
}
}
},
{
"class": "property",
"content": {
"name": {
"literal": "name"
},
"valueDefinition": {
"values": [
{
"literal": "A green door"
}
]
}
}
},
{
"class": "property",
"content": {
"name": {
"literal": "price"
},
"valueDefinition": {
"values": [
{
"literal": "12.50"
}
],
"typeDefinition": {
"typeSpecification": {
"name": "number"
}
}
}
}
},
{
"class": "property",
"content": {
"name": {
"literal": "tags"
},
"valueDefinition": {
"values": [
{
"literal": "home"
},
{
"literal": "green"
}
]
}
}
},
{
"class": "property",
"content": {
"name": {
"literal": "vector"
},
"valueDefinition": {
"typeDefinition": {
"typeSpecification": {
"name": "array"
}
}
},
"sections": [
{
"class": "memberType",
"content": [
{
"class": "value",
"content": {
"valueDefinition": {
"values": [
{
"literal": "1"
}
]
}
}
},
{
"class": "value",
"content": {
"valueDefinition": {
"values": [
{
"literal": "2"
}
]
}
}
},
{
"class": "value",
"content": {
"valueDefinition": {
"values": [
{
"literal": "3"
}
]
}
}
}
]
}
]
}
}
]
}
]
}
]
}
MIT License. See the LICENSE file.