redsnow 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/snowcrash.xcworkspace/contents.xcworkspacedata +10 -0
- data/ext/snowcrash/src/ActionParser.h +35 -33
- data/ext/snowcrash/src/AssetParser.h +17 -17
- data/ext/snowcrash/src/Blueprint.h +101 -66
- data/ext/snowcrash/src/BlueprintParser.h +219 -10
- data/ext/snowcrash/src/BlueprintSourcemap.h +1 -1
- data/ext/snowcrash/src/BlueprintUtility.h +14 -14
- data/ext/snowcrash/src/CBlueprint.cc +29 -10
- data/ext/snowcrash/src/CBlueprint.h +19 -3
- data/ext/snowcrash/src/CBlueprintSourcemap.cc +20 -10
- data/ext/snowcrash/src/CBlueprintSourcemap.h +12 -3
- data/ext/snowcrash/src/CodeBlockUtility.h +25 -25
- data/ext/snowcrash/src/HTTP.cc +3 -0
- data/ext/snowcrash/src/HTTP.h +9 -6
- data/ext/snowcrash/src/HeadersParser.h +34 -14
- data/ext/snowcrash/src/ParameterParser.h +21 -21
- data/ext/snowcrash/src/ParametersParser.h +6 -5
- data/ext/snowcrash/src/PayloadParser.h +174 -129
- data/ext/snowcrash/src/RegexMatch.h +3 -3
- data/ext/snowcrash/src/ResourceGroupParser.h +5 -4
- data/ext/snowcrash/src/ResourceParser.h +30 -26
- data/ext/snowcrash/src/Section.cc +6 -6
- data/ext/snowcrash/src/Section.h +2 -2
- data/ext/snowcrash/src/SectionParser.h +41 -41
- data/ext/snowcrash/src/SectionParserData.h +10 -10
- data/ext/snowcrash/src/SectionProcessor.h +70 -30
- data/ext/snowcrash/src/Serialize.h +3 -3
- data/ext/snowcrash/src/SerializeJSON.cc +124 -96
- data/ext/snowcrash/src/SerializeJSON.h +1 -1
- data/ext/snowcrash/src/SerializeYAML.cc +71 -53
- data/ext/snowcrash/src/SerializeYAML.h +1 -1
- data/ext/snowcrash/src/Signature.cc +2 -2
- data/ext/snowcrash/src/Signature.h +1 -1
- data/ext/snowcrash/src/SourceAnnotation.h +23 -23
- data/ext/snowcrash/src/StringUtility.h +71 -9
- data/ext/snowcrash/src/SymbolTable.h +17 -17
- data/ext/snowcrash/src/UriTemplateParser.cc +5 -5
- data/ext/snowcrash/src/UriTemplateParser.h +9 -9
- data/ext/snowcrash/src/ValuesParser.h +2 -2
- data/ext/snowcrash/src/Version.h +1 -1
- data/ext/snowcrash/src/csnowcrash.cc +10 -8
- data/ext/snowcrash/src/snowcrash.cc +9 -9
- data/ext/snowcrash/src/snowcrash.h +6 -8
- data/ext/snowcrash/src/snowcrash/snowcrash.cc +14 -14
- data/ext/snowcrash/src/win/RegexMatch.cc +7 -7
- data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/snowcrash/tools/homebrew/snowcrash.rb +1 -1
- data/lib/redsnow/binding.rb +8 -2
- data/lib/redsnow/blueprint.rb +4 -3
- data/lib/redsnow/sourcemap.rb +6 -4
- data/lib/redsnow/version.rb +1 -1
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95878106472075ff91ed563622ec6285529c0530
|
4
|
+
data.tar.gz: dc6cda45a08da74637a36db527bff272491c24d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c9c951c99b4fa2062b8d5673f2567a830e078e77549889924804cb4af80583c532c5f555299fb6a0dee424afd7ffd7a772ea3419f50d9e79b34a80002316eb3
|
7
|
+
data.tar.gz: 43dd575341b35f7f7f02b3603d69e60afe543322c4d903b8259a6c808028cf4bd922dc9a756f3f4de9abefebfa6d7c057675c9fa9c4bd363b11a3a4f3bdc70ce
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Changelog
|
2
|
+
- 0.3.0
|
3
|
+
- [Format 1A7](https://github.com/apiaryio/api-blueprint/releases/tag/format-1A7) support. [Snow Crash v0.16.0](https://github.com/apiaryio/snowcrash/releases/tag/v0.16.0)
|
2
4
|
- 0.2.1
|
3
5
|
- Support for source maps [Snow Crash v0.15.0](https://github.com/apiaryio/snowcrash/releases/tag/v0.15.0) and [AST Serialization Format 2.1](https://github.com/apiaryio/api-blueprint-ast/releases/tag/v2.1).
|
4
6
|
- 0.2.0
|
data/ext/snowcrash/bin/snowcrash
CHANGED
Binary file
|
@@ -25,7 +25,7 @@ namespace snowcrash {
|
|
25
25
|
|
26
26
|
/** Internal type alias for Collection iterator of Action */
|
27
27
|
typedef Collection<Action>::const_iterator ActionIterator;
|
28
|
-
|
28
|
+
|
29
29
|
/** Action Definition Type */
|
30
30
|
enum ActionType {
|
31
31
|
NotActionType = 0,
|
@@ -44,7 +44,7 @@ namespace snowcrash {
|
|
44
44
|
const MarkdownNodes& siblings,
|
45
45
|
SectionParserData& pd,
|
46
46
|
SectionLayout& layout,
|
47
|
-
|
47
|
+
const ParseResultRef<Action>& out) {
|
48
48
|
|
49
49
|
actionHTTPMethodAndName(node, out.node.method, out.node.name);
|
50
50
|
TrimString(out.node.name);
|
@@ -76,7 +76,7 @@ namespace snowcrash {
|
|
76
76
|
static MarkdownNodeIterator processNestedSection(const MarkdownNodeIterator& node,
|
77
77
|
const MarkdownNodes& siblings,
|
78
78
|
SectionParserData& pd,
|
79
|
-
|
79
|
+
const ParseResultRef<Action>& out) {
|
80
80
|
|
81
81
|
SectionType sectionType = pd.sectionContext();
|
82
82
|
MarkdownNodeIterator cur = node;
|
@@ -87,14 +87,15 @@ namespace snowcrash {
|
|
87
87
|
switch (sectionType) {
|
88
88
|
case ParametersSectionType:
|
89
89
|
{
|
90
|
-
|
90
|
+
ParseResultRef<Parameters> parameters(out.report, out.node.parameters, out.sourceMap.parameters);
|
91
91
|
return ParametersParser::parse(node, siblings, pd, parameters);
|
92
92
|
}
|
93
93
|
|
94
94
|
case RequestSectionType:
|
95
95
|
case RequestBodySectionType:
|
96
96
|
{
|
97
|
-
|
97
|
+
IntermediateParseResult<Payload> payload(out.report);
|
98
|
+
|
98
99
|
cur = PayloadParser::parse(node, siblings, pd, payload);
|
99
100
|
|
100
101
|
if (out.node.examples.empty() || !out.node.examples.back().responses.empty()) {
|
@@ -122,7 +123,8 @@ namespace snowcrash {
|
|
122
123
|
case ResponseSectionType:
|
123
124
|
case ResponseBodySectionType:
|
124
125
|
{
|
125
|
-
|
126
|
+
IntermediateParseResult<Payload> payload(out.report);
|
127
|
+
|
126
128
|
cur = PayloadParser::parse(node, siblings, pd, payload);
|
127
129
|
|
128
130
|
if (out.node.examples.empty()) {
|
@@ -149,7 +151,7 @@ namespace snowcrash {
|
|
149
151
|
|
150
152
|
case HeadersSectionType:
|
151
153
|
{
|
152
|
-
|
154
|
+
ParseResultRef<Headers> headers(out.report, out.node.headers, out.sourceMap.headers);
|
153
155
|
return SectionProcessor<Action>::handleDeprecatedHeaders(node, siblings, pd, headers);
|
154
156
|
}
|
155
157
|
|
@@ -162,19 +164,19 @@ namespace snowcrash {
|
|
162
164
|
|
163
165
|
static bool isUnexpectedNode(const MarkdownNodeIterator& node,
|
164
166
|
SectionType sectionType) {
|
165
|
-
|
167
|
+
|
166
168
|
if (SectionProcessor<Asset>::sectionType(node) != UndefinedSectionType) {
|
167
169
|
return true;
|
168
170
|
}
|
169
|
-
|
171
|
+
|
170
172
|
return SectionProcessorBase<Action>::isUnexpectedNode(node, sectionType);
|
171
173
|
}
|
172
|
-
|
174
|
+
|
173
175
|
static MarkdownNodeIterator processUnexpectedNode(const MarkdownNodeIterator& node,
|
174
176
|
const MarkdownNodes& siblings,
|
175
177
|
SectionParserData& pd,
|
176
178
|
SectionType& sectionType,
|
177
|
-
|
179
|
+
const ParseResultRef<Action>& out) {
|
178
180
|
|
179
181
|
if ((node->type == mdp::ParagraphMarkdownNodeType ||
|
180
182
|
node->type == mdp::CodeMarkdownNodeType) &&
|
@@ -191,14 +193,14 @@ namespace snowcrash {
|
|
191
193
|
|
192
194
|
return ++MarkdownNodeIterator(node);
|
193
195
|
}
|
194
|
-
|
196
|
+
|
195
197
|
if ((node->type == mdp::ParagraphMarkdownNodeType ||
|
196
198
|
node->type == mdp::CodeMarkdownNodeType) &&
|
197
199
|
(sectionType == RequestBodySectionType ||
|
198
200
|
sectionType == RequestSectionType) &&
|
199
201
|
!out.node.examples.empty() &&
|
200
202
|
!out.node.examples.back().requests.empty()) {
|
201
|
-
|
203
|
+
|
202
204
|
mdp::ByteBuffer content = CodeBlockUtility::addDanglingAsset(node, pd, sectionType, out.report, out.node.examples.back().requests.back().body);
|
203
205
|
|
204
206
|
if (pd.exportSourceMap() && !content.empty()) {
|
@@ -207,15 +209,15 @@ namespace snowcrash {
|
|
207
209
|
|
208
210
|
return ++MarkdownNodeIterator(node);
|
209
211
|
}
|
210
|
-
|
212
|
+
|
211
213
|
SectionType assetType = SectionProcessor<Asset>::sectionType(node);
|
212
|
-
|
214
|
+
|
213
215
|
if (assetType != UndefinedSectionType) {
|
214
|
-
|
216
|
+
|
215
217
|
// WARN: Ignoring section
|
216
218
|
std::stringstream ss;
|
217
219
|
mdp::CharactersRangeSet sourceMap = mdp::BytesRangeSetToCharactersRangeSet(node->sourceMap, pd.sourceData);
|
218
|
-
|
220
|
+
|
219
221
|
ss << "Ignoring " << SectionName(assetType) << " list item, ";
|
220
222
|
ss << SectionName(assetType) << " list item is expected to be indented by 4 spaces or 1 tab";
|
221
223
|
|
@@ -225,8 +227,8 @@ namespace snowcrash {
|
|
225
227
|
|
226
228
|
return ++MarkdownNodeIterator(node);
|
227
229
|
}
|
228
|
-
|
229
|
-
return SectionProcessorBase<Action>::processUnexpectedNode(node, siblings, pd, sectionType, out);
|
230
|
+
|
231
|
+
return SectionProcessorBase<Action>::processUnexpectedNode(node, siblings, pd, sectionType, out);
|
230
232
|
}
|
231
233
|
|
232
234
|
static SectionType sectionType(const MarkdownNodeIterator& node) {
|
@@ -292,7 +294,7 @@ namespace snowcrash {
|
|
292
294
|
|
293
295
|
static void finalize(const MarkdownNodeIterator& node,
|
294
296
|
SectionParserData& pd,
|
295
|
-
|
297
|
+
const ParseResultRef<Action>& out) {
|
296
298
|
|
297
299
|
if (!out.node.headers.empty()) {
|
298
300
|
|
@@ -343,7 +345,7 @@ namespace snowcrash {
|
|
343
345
|
static void checkPayload(SectionType sectionType,
|
344
346
|
const mdp::CharactersRangeSet sourceMap,
|
345
347
|
const Payload& payload,
|
346
|
-
|
348
|
+
const ParseResultRef<Action>& out) {
|
347
349
|
|
348
350
|
if (isPayloadDuplicate(sectionType, payload, out.node.examples.back())) {
|
349
351
|
|
@@ -418,7 +420,7 @@ namespace snowcrash {
|
|
418
420
|
static MarkdownNodeIterator handleDeprecatedHeaders(const MarkdownNodeIterator& node,
|
419
421
|
const MarkdownNodes& siblings,
|
420
422
|
SectionParserData& pd,
|
421
|
-
|
423
|
+
const ParseResultRef<Headers>& out) {
|
422
424
|
|
423
425
|
MarkdownNodeIterator cur = HeadersParser::parse(node, siblings, pd, out);
|
424
426
|
|
@@ -433,23 +435,23 @@ namespace snowcrash {
|
|
433
435
|
|
434
436
|
return cur;
|
435
437
|
}
|
436
|
-
|
438
|
+
|
437
439
|
/** \return %ActionType of a node */
|
438
440
|
static ActionType actionType(const MarkdownNodeIterator& node) {
|
439
|
-
|
441
|
+
|
440
442
|
if (node->type != mdp::HeaderMarkdownNodeType || node->text.empty())
|
441
443
|
return NotActionType;
|
442
|
-
|
444
|
+
|
443
445
|
mdp::ByteBuffer subject = node->text;
|
444
446
|
TrimString(subject);
|
445
|
-
|
447
|
+
|
446
448
|
if (RegexMatch(subject, NamedActionHeaderRegex)) {
|
447
449
|
return DependentActionType;
|
448
450
|
}
|
449
|
-
|
451
|
+
|
450
452
|
CaptureGroups captureGroups;
|
451
453
|
if (RegexCapture(subject, ActionHeaderRegex, captureGroups, 3)) {
|
452
|
-
|
454
|
+
|
453
455
|
if (captureGroups[2].empty()) {
|
454
456
|
return DependentActionType;
|
455
457
|
}
|
@@ -457,7 +459,7 @@ namespace snowcrash {
|
|
457
459
|
return CompleteActionType;
|
458
460
|
}
|
459
461
|
}
|
460
|
-
|
462
|
+
|
461
463
|
return NotActionType;
|
462
464
|
}
|
463
465
|
|
@@ -465,20 +467,20 @@ namespace snowcrash {
|
|
465
467
|
static void actionHTTPMethodAndName(const MarkdownNodeIterator& node,
|
466
468
|
mdp::ByteBuffer& method,
|
467
469
|
mdp::ByteBuffer& name) {
|
468
|
-
|
470
|
+
|
469
471
|
CaptureGroups captureGroups;
|
470
472
|
mdp::ByteBuffer subject, remaining;
|
471
|
-
|
473
|
+
|
472
474
|
subject = GetFirstLine(node->text, remaining);
|
473
475
|
TrimString(subject);
|
474
|
-
|
476
|
+
|
475
477
|
if (RegexCapture(subject, ActionHeaderRegex, captureGroups, 3)) {
|
476
478
|
method = captureGroups[1];
|
477
479
|
} else if (RegexCapture(subject, NamedActionHeaderRegex, captureGroups, 3)) {
|
478
480
|
name = captureGroups[1];
|
479
481
|
method = captureGroups[2];
|
480
482
|
}
|
481
|
-
|
483
|
+
|
482
484
|
return;
|
483
485
|
}
|
484
486
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
#include "CodeBlockUtility.h"
|
15
15
|
|
16
16
|
namespace snowcrash {
|
17
|
-
|
17
|
+
|
18
18
|
/// Asset signature
|
19
19
|
enum AssetSignature {
|
20
20
|
NoAssetSignature = 0,
|
@@ -23,7 +23,7 @@ namespace snowcrash {
|
|
23
23
|
SchemaAssetSignature, /// < Explicit Schema asset
|
24
24
|
UndefinedAssetSignature = -1
|
25
25
|
};
|
26
|
-
|
26
|
+
|
27
27
|
/** Body matching regex */
|
28
28
|
const char* const BodyRegex = "^[[:blank:]]*[Bb]ody[[:blank:]]*$";
|
29
29
|
|
@@ -35,13 +35,13 @@ namespace snowcrash {
|
|
35
35
|
*/
|
36
36
|
template<>
|
37
37
|
struct SectionProcessor<Asset> : public SectionProcessorBase<Asset> {
|
38
|
-
|
38
|
+
|
39
39
|
static MarkdownNodeIterator processSignature(const MarkdownNodeIterator& node,
|
40
40
|
const MarkdownNodes& siblings,
|
41
41
|
SectionParserData& pd,
|
42
42
|
SectionLayout& layout,
|
43
|
-
|
44
|
-
|
43
|
+
const ParseResultRef<Asset>& out) {
|
44
|
+
|
45
45
|
out.node = "";
|
46
46
|
CodeBlockUtility::signatureContentAsCodeBlock(node, pd, out.report, out.node);
|
47
47
|
|
@@ -51,11 +51,11 @@ namespace snowcrash {
|
|
51
51
|
|
52
52
|
return ++MarkdownNodeIterator(node);
|
53
53
|
}
|
54
|
-
|
54
|
+
|
55
55
|
static MarkdownNodeIterator processDescription(const MarkdownNodeIterator& node,
|
56
56
|
const MarkdownNodes& siblings,
|
57
57
|
SectionParserData& pd,
|
58
|
-
|
58
|
+
const ParseResultRef<Asset>& out) {
|
59
59
|
|
60
60
|
return node;
|
61
61
|
}
|
@@ -63,8 +63,8 @@ namespace snowcrash {
|
|
63
63
|
static MarkdownNodeIterator processContent(const MarkdownNodeIterator& node,
|
64
64
|
const MarkdownNodes& siblings,
|
65
65
|
SectionParserData& pd,
|
66
|
-
|
67
|
-
|
66
|
+
const ParseResultRef<Asset>& out) {
|
67
|
+
|
68
68
|
mdp::ByteBuffer content;
|
69
69
|
CodeBlockUtility::contentAsCodeBlock(node, pd, out.report, content);
|
70
70
|
|
@@ -76,18 +76,18 @@ namespace snowcrash {
|
|
76
76
|
|
77
77
|
return ++MarkdownNodeIterator(node);
|
78
78
|
}
|
79
|
-
|
79
|
+
|
80
80
|
static bool isDescriptionNode(const MarkdownNodeIterator& node,
|
81
81
|
SectionType sectionType) {
|
82
82
|
return false;
|
83
83
|
}
|
84
|
-
|
84
|
+
|
85
85
|
static bool isContentNode(const MarkdownNodeIterator& node,
|
86
86
|
SectionType sectionType) {
|
87
87
|
|
88
88
|
return (SectionKeywordSignature(node) == UndefinedSectionType);
|
89
89
|
}
|
90
|
-
|
90
|
+
|
91
91
|
static SectionType sectionType(const MarkdownNodeIterator& node) {
|
92
92
|
if (node->type == mdp::ListItemMarkdownNodeType
|
93
93
|
&& !node->children().empty()) {
|
@@ -101,7 +101,7 @@ namespace snowcrash {
|
|
101
101
|
|
102
102
|
case SchemaAssetSignature:
|
103
103
|
return SchemaSectionType;
|
104
|
-
|
104
|
+
|
105
105
|
default:
|
106
106
|
return UndefinedSectionType;
|
107
107
|
}
|
@@ -109,24 +109,24 @@ namespace snowcrash {
|
|
109
109
|
|
110
110
|
return UndefinedSectionType;
|
111
111
|
}
|
112
|
-
|
112
|
+
|
113
113
|
/** Resolve asset signature */
|
114
114
|
static AssetSignature assetSignature(const MarkdownNodeIterator& node) {
|
115
115
|
|
116
116
|
mdp::ByteBuffer remaining, subject = node->children().front().text;
|
117
117
|
subject = GetFirstLine(subject, remaining);
|
118
118
|
TrimString(subject);
|
119
|
-
|
119
|
+
|
120
120
|
if (RegexMatch(subject, BodyRegex))
|
121
121
|
return BodyAssetSignature;
|
122
122
|
|
123
123
|
if (RegexMatch(subject, SchemaRegex))
|
124
124
|
return SchemaAssetSignature;
|
125
|
-
|
125
|
+
|
126
126
|
return NoAssetSignature;
|
127
127
|
}
|
128
128
|
};
|
129
|
-
|
129
|
+
|
130
130
|
/** Asset Section Parser */
|
131
131
|
typedef SectionParser<Asset, ListSectionAdapter> AssetParser;
|
132
132
|
}
|
@@ -13,6 +13,7 @@
|
|
13
13
|
#include <string>
|
14
14
|
#include <utility>
|
15
15
|
#include "Platform.h"
|
16
|
+
#include "MarkdownNode.h"
|
16
17
|
|
17
18
|
/**
|
18
19
|
* API Blueprint Abstract Syntax Tree
|
@@ -22,36 +23,36 @@
|
|
22
23
|
*/
|
23
24
|
|
24
25
|
namespace snowcrash {
|
25
|
-
|
26
|
+
|
26
27
|
/** Name of a an API Blueprint entity. */
|
27
28
|
typedef std::string Name;
|
28
29
|
|
29
|
-
/**
|
30
|
+
/**
|
30
31
|
* \brief An API Blueprint entity Description.
|
31
32
|
*
|
32
|
-
* Depending on parser setting the description might be
|
33
|
+
* Depending on parser setting the description might be
|
33
34
|
* rendered HTML from Markdown or raw Markdown.
|
34
35
|
*/
|
35
36
|
typedef std::string Description;
|
36
|
-
|
37
|
+
|
37
38
|
/** URI */
|
38
39
|
typedef std::string URI;
|
39
|
-
|
40
|
+
|
40
41
|
/** URI template */
|
41
42
|
typedef std::string URITemplate;
|
42
|
-
|
43
|
+
|
43
44
|
/** HTTP Method */
|
44
45
|
typedef std::string HTTPMethod;
|
45
46
|
|
46
47
|
/** Parameter Type */
|
47
48
|
typedef std::string Type;
|
48
|
-
|
49
|
+
|
49
50
|
/** Parameter Value */
|
50
51
|
typedef std::string Value;
|
51
52
|
|
52
53
|
/** A generic key - value pair */
|
53
54
|
typedef std::pair<std::string, std::string> KeyValuePair;
|
54
|
-
|
55
|
+
|
55
56
|
/**
|
56
57
|
* Default Container for collections.
|
57
58
|
*
|
@@ -63,18 +64,18 @@ namespace snowcrash {
|
|
63
64
|
typedef typename std::vector<T>::iterator iterator;
|
64
65
|
typedef typename std::vector<T>::const_iterator const_iterator;
|
65
66
|
};
|
66
|
-
|
67
|
+
|
67
68
|
/** An asset data */
|
68
69
|
typedef std::string Asset;
|
69
70
|
|
70
|
-
/**
|
71
|
+
/**
|
71
72
|
* \brief Metadata key-value pair,
|
72
73
|
*
|
73
74
|
* E.g. "HOST: http://acme.com"
|
74
75
|
*/
|
75
76
|
typedef KeyValuePair Metadata;
|
76
77
|
|
77
|
-
/**
|
78
|
+
/**
|
78
79
|
* \brief Header key-value pair.
|
79
80
|
*
|
80
81
|
* E.g. "Content-Type: application/json"
|
@@ -86,7 +87,7 @@ namespace snowcrash {
|
|
86
87
|
|
87
88
|
/** Headers */
|
88
89
|
typedef Collection<Header>::type Headers;
|
89
|
-
|
90
|
+
|
90
91
|
/** Collection of Parameter Values */
|
91
92
|
typedef Collection<Value>::type Values;
|
92
93
|
|
@@ -96,28 +97,28 @@ namespace snowcrash {
|
|
96
97
|
OptionalParameterUse,
|
97
98
|
RequiredParameterUse
|
98
99
|
};
|
99
|
-
|
100
|
+
|
100
101
|
/** Parameter */
|
101
102
|
struct Parameter {
|
102
|
-
|
103
|
+
|
103
104
|
/** Parameter Name */
|
104
105
|
Name name;
|
105
|
-
|
106
|
+
|
106
107
|
/** Parameter Description */
|
107
108
|
Description description;
|
108
|
-
|
109
|
+
|
109
110
|
/** Type */
|
110
111
|
Type type;
|
111
|
-
|
112
|
+
|
112
113
|
/** Required flag */
|
113
114
|
ParameterUse use;
|
114
|
-
|
115
|
+
|
115
116
|
/** Default Value, applicable only when `required == false` */
|
116
117
|
Value defaultValue;
|
117
|
-
|
118
|
+
|
118
119
|
/** Example Value */
|
119
120
|
Value exampleValue;
|
120
|
-
|
121
|
+
|
121
122
|
/** Enumeration of possible values */
|
122
123
|
Values values;
|
123
124
|
};
|
@@ -125,50 +126,84 @@ namespace snowcrash {
|
|
125
126
|
/** Source Map of Collection of Parameters */
|
126
127
|
typedef Collection<Parameter>::type Parameters;
|
127
128
|
|
128
|
-
/**
|
129
|
-
typedef std::string
|
129
|
+
/** Identifier(name) of Reference */
|
130
|
+
typedef std::string Identifier;
|
131
|
+
|
132
|
+
/** Reference */
|
133
|
+
struct Reference {
|
134
|
+
|
135
|
+
/** Reference Resolution State */
|
136
|
+
enum State {
|
137
|
+
StateUnresolved, // Reference unresolved (undefined)
|
138
|
+
StatePending, // Reference resolution pending
|
139
|
+
StateResolved // Reference resolved successfully
|
140
|
+
};
|
141
|
+
|
142
|
+
/** Reference Type */
|
143
|
+
enum ReferenceType {
|
144
|
+
SymbolReference // Reference as symbol
|
145
|
+
};
|
146
|
+
|
147
|
+
/** Identifier */
|
148
|
+
Identifier id;
|
149
|
+
|
150
|
+
/** Type */
|
151
|
+
ReferenceType type;
|
152
|
+
|
153
|
+
struct ReferenceMetadata {
|
154
|
+
|
155
|
+
/** Markdown AST reference source node (for source map) */
|
156
|
+
mdp::MarkdownNodeIterator node;
|
157
|
+
|
158
|
+
/** Reference resolution state */
|
159
|
+
State state;
|
160
|
+
};
|
161
|
+
|
162
|
+
/** Metadata for the reference */
|
163
|
+
ReferenceMetadata meta;
|
164
|
+
};
|
130
165
|
|
131
166
|
/**
|
132
167
|
* Payload
|
133
168
|
*/
|
134
169
|
struct Payload {
|
135
|
-
|
170
|
+
|
136
171
|
/** A Payload Name */
|
137
172
|
Name name;
|
138
|
-
|
173
|
+
|
139
174
|
/** Payload Description */
|
140
175
|
Description description;
|
141
|
-
|
176
|
+
|
142
177
|
/** Payload-specific Parameters */
|
143
178
|
Parameters parameters;
|
144
|
-
|
179
|
+
|
145
180
|
/** Payload-specific Headers */
|
146
181
|
Headers headers;
|
147
|
-
|
182
|
+
|
148
183
|
/** Body */
|
149
184
|
Asset body;
|
150
|
-
|
185
|
+
|
151
186
|
/** Schema */
|
152
187
|
Asset schema;
|
153
188
|
|
154
|
-
/**
|
155
|
-
|
189
|
+
/** Reference */
|
190
|
+
Reference reference;
|
156
191
|
};
|
157
|
-
|
192
|
+
|
158
193
|
/** Resource Model */
|
159
194
|
typedef Payload ResourceModel;
|
160
|
-
|
195
|
+
|
161
196
|
/** Request */
|
162
197
|
typedef Payload Request;
|
163
|
-
|
164
|
-
/**
|
198
|
+
|
199
|
+
/**
|
165
200
|
* \brief Response
|
166
201
|
*
|
167
202
|
* A payload returned in a response to an action.
|
168
203
|
* Payload's name represents the HTTP status code.
|
169
204
|
*/
|
170
205
|
typedef Payload Response;
|
171
|
-
|
206
|
+
|
172
207
|
/** Collection of Requests */
|
173
208
|
typedef Collection<Request>::type Requests;
|
174
209
|
|
@@ -179,20 +214,20 @@ namespace snowcrash {
|
|
179
214
|
* An HTTP transaction example.
|
180
215
|
*/
|
181
216
|
struct TransactionExample {
|
182
|
-
|
217
|
+
|
183
218
|
/** An example name */
|
184
219
|
Name name;
|
185
|
-
|
220
|
+
|
186
221
|
/** Description */
|
187
222
|
Description description;
|
188
|
-
|
223
|
+
|
189
224
|
/** Requests */
|
190
225
|
Requests requests;
|
191
|
-
|
226
|
+
|
192
227
|
/** Responses */
|
193
228
|
Responses responses;
|
194
229
|
};
|
195
|
-
|
230
|
+
|
196
231
|
/** Collection of Transaction examples */
|
197
232
|
typedef Collection<TransactionExample>::type TransactionExamples;
|
198
233
|
|
@@ -200,37 +235,37 @@ namespace snowcrash {
|
|
200
235
|
* Action
|
201
236
|
*/
|
202
237
|
struct Action {
|
203
|
-
|
238
|
+
|
204
239
|
/** HTTP method */
|
205
240
|
HTTPMethod method;
|
206
|
-
|
241
|
+
|
207
242
|
/** An Action name */
|
208
243
|
Name name;
|
209
|
-
|
244
|
+
|
210
245
|
/** Description */
|
211
246
|
Description description;
|
212
|
-
|
247
|
+
|
213
248
|
/** Action-specific Parameters */
|
214
249
|
Parameters parameters;
|
215
|
-
|
216
|
-
/**
|
250
|
+
|
251
|
+
/**
|
217
252
|
* \brief Action-specific HTTP headers
|
218
253
|
*
|
219
254
|
* DEPRECATION WARNING:
|
220
255
|
* --------------------
|
221
256
|
*
|
222
257
|
* This AST node is build for deprecated API Blueprint syntax
|
223
|
-
* and as such it will be removed in a future version of
|
224
|
-
* Snow Crash.
|
225
|
-
*
|
258
|
+
* and as such it will be removed in a future version of
|
259
|
+
* Snow Crash.
|
260
|
+
*
|
226
261
|
* Use respective payload's header collection instead.
|
227
262
|
*/
|
228
263
|
DEPRECATED Headers headers;
|
229
|
-
|
264
|
+
|
230
265
|
/** Transactions examples */
|
231
266
|
TransactionExamples examples;
|
232
267
|
};
|
233
|
-
|
268
|
+
|
234
269
|
/** Collection of Actions */
|
235
270
|
typedef Collection<Action>::type Actions;
|
236
271
|
|
@@ -238,22 +273,22 @@ namespace snowcrash {
|
|
238
273
|
* API Resource
|
239
274
|
*/
|
240
275
|
struct Resource {
|
241
|
-
|
276
|
+
|
242
277
|
/** URI template */
|
243
278
|
URITemplate uriTemplate;
|
244
|
-
|
279
|
+
|
245
280
|
/** A Resource Name */
|
246
281
|
Name name;
|
247
|
-
|
282
|
+
|
248
283
|
/** Description of the resource */
|
249
284
|
Description description;
|
250
|
-
|
285
|
+
|
251
286
|
/** Model representing this Resource */
|
252
287
|
ResourceModel model;
|
253
|
-
|
288
|
+
|
254
289
|
/** Parameters */
|
255
290
|
Parameters parameters;
|
256
|
-
|
291
|
+
|
257
292
|
/**
|
258
293
|
* \brief Resource-specific HTTP Headers
|
259
294
|
*
|
@@ -267,11 +302,11 @@ namespace snowcrash {
|
|
267
302
|
* Use respective payload's header collection instead.
|
268
303
|
*/
|
269
304
|
DEPRECATED Headers headers;
|
270
|
-
|
305
|
+
|
271
306
|
/** A set of Actions specified for this Resource */
|
272
307
|
Actions actions;
|
273
308
|
};
|
274
|
-
|
309
|
+
|
275
310
|
/** Collection of Resources */
|
276
311
|
typedef Collection<Resource>::type Resources;
|
277
312
|
|
@@ -279,13 +314,13 @@ namespace snowcrash {
|
|
279
314
|
* Group of API Resources
|
280
315
|
*/
|
281
316
|
struct ResourceGroup {
|
282
|
-
|
317
|
+
|
283
318
|
/** A Group Name */
|
284
319
|
Name name;
|
285
|
-
|
320
|
+
|
286
321
|
/** Group description */
|
287
322
|
Description description;
|
288
|
-
|
323
|
+
|
289
324
|
/** Resources */
|
290
325
|
Resources resources;
|
291
326
|
};
|
@@ -293,23 +328,23 @@ namespace snowcrash {
|
|
293
328
|
/** Collection of Resource groups */
|
294
329
|
typedef Collection<ResourceGroup>::type ResourceGroups;
|
295
330
|
|
296
|
-
/**
|
331
|
+
/**
|
297
332
|
* \brief API Blueprint AST
|
298
333
|
*
|
299
334
|
* This is top-level (or root if you prefer) of API Blueprint abstract syntax tree.
|
300
335
|
* Start reading a parsed API here.
|
301
336
|
*/
|
302
337
|
struct Blueprint {
|
303
|
-
|
338
|
+
|
304
339
|
/** Metadata */
|
305
340
|
MetadataCollection metadata;
|
306
|
-
|
341
|
+
|
307
342
|
/** The API Name */
|
308
343
|
Name name;
|
309
344
|
|
310
345
|
/** An API Overview description */
|
311
346
|
Description description;
|
312
|
-
|
347
|
+
|
313
348
|
/** The set of API Resource Groups */
|
314
349
|
ResourceGroups resourceGroups;
|
315
350
|
};
|