Skip to content

Commit 9a1a927

Browse files
committed
Merge pull request #19 from refractproject/zdne/api-namespace.md
API Namespace origin
2 parents bf60776 + 4413652 commit 9a1a927

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Refract is a a recursive data structure for expressing complex structures, relat
77
- [Full Specification](refract-spec.md)
88
- [MSON Namespace](namespaces/mson-namespace.md)
99
- [Resource Namespace](namespaces/resource-namespace.md)
10+
- [API Namespace](namespaces/api-namespace.md)
1011

1112
## Version
1213

namespaces/api-namespace.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# API Namespace
2+
3+
This document extends [Refract][] [Resource Namespace][] to define REST API data structure elements.
4+
5+
## Content
6+
7+
<!-- TOC depth:2 withLinks:1 updateOnSave:1 -->
8+
- [API Namespace](#api-namespace)
9+
- [Content](#content)
10+
- [About this Document](#about-this-document)
11+
- [Category (Element)](#category-element)
12+
- [Copy (Element)](#copy-element)
13+
<!-- /TOC -->
14+
15+
## About this Document
16+
17+
This document conforms to [RFC 2119][], which says:
18+
19+
> 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 RFC 2119.
20+
21+
[MSON][] is used throughout this document.
22+
23+
## Category (Element)
24+
25+
Grouping element – a set of elements forming a logical unit of an API such as
26+
group of related resources or data structures.
27+
28+
A category element MAY include additional classification of the category.
29+
The classification MAY hint what is the content or semantics of the category.
30+
The classification MAY be extended and MAY contain more than one classes.
31+
32+
For example a `category` element may be classified both as `resourceGroup` and
33+
`dataStructures` to denote it includes both resource and data structures.
34+
35+
### Properties
36+
37+
- `element`: category (string, fixed)
38+
- `meta`
39+
- `class` (array, fixed)
40+
- (enum[string])
41+
- api - Category is a API top-level group.
42+
- resourceGroup - Category is a set of resource.
43+
- dataStructures - Category is a set of data structures.
44+
- scenario - Reserved. Category is set of steps.
45+
- `content` (array[Element])
46+
47+
### Example
48+
49+
```json
50+
{
51+
"element": "category",
52+
"meta": {
53+
"class": [
54+
"api"
55+
],
56+
"title": "Polls API"
57+
},
58+
"content": [
59+
{
60+
"element": "category",
61+
"meta": {
62+
"class": [
63+
"resourceGroup"
64+
],
65+
"title": "Question",
66+
"description": "Resources related to questions in the API."
67+
},
68+
"content": []
69+
}
70+
]
71+
}
72+
```
73+
74+
## Copy (Element)
75+
76+
Copy element represents a copy text. A textual information in API description.
77+
Its content is a string and it MAY include information about the media type
78+
of the copy's content.
79+
80+
If an element contains a Copy element, the element's `description` metadata
81+
MAY include the Copy element's content.
82+
83+
The Copy element MAY appear as a content of any element defined in the base
84+
namespaces.
85+
86+
### Properties
87+
88+
- `element`: copy (string, fixed)
89+
- `attributes` (object)
90+
- `contentType`: *text/plain* (string) - Optional media type of the content.
91+
- `content` (string)
92+
93+
### Example
94+
95+
Given an API description with following layout:
96+
97+
- Group
98+
- Copy "Lorem Ipsum"
99+
- Resource "A"
100+
- Resource "B"
101+
- Copy "Dolor Sit Amet"
102+
103+
```json
104+
{
105+
"element": "category",
106+
"meta": {
107+
"description": "Lorem Ipsum\nDolor Sit Amet"
108+
},
109+
"content": [
110+
{
111+
"element": "copy",
112+
"content": "Lorem Ipsum"
113+
},
114+
{
115+
"element": "resource"
116+
},
117+
{
118+
"element": "resource"
119+
},
120+
{
121+
"element": "copy",
122+
"content": "Dolor Sit Amet"
123+
}
124+
]
125+
}
126+
```
127+
128+
---
129+
130+
[MSON]: https://github.com/apiaryio/mson
131+
[Refract]: ../refract-spec.md
132+
[MSON Namespace]: mson-namespace.md
133+
[Resource Namespace]: resource-namespace.md

0 commit comments

Comments
 (0)