apib2swagger 1.10.0 → 1.14.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.
- package/.github/workflows/codeql-analysis.yml +71 -0
- package/.github/workflows/docker-publish.yml +70 -0
- package/.github/workflows/nodejs.yml +26 -0
- package/.travis.yml +2 -3
- package/Dockerfile +5 -0
- package/LICENSE +0 -0
- package/README.md +31 -10
- package/bin/apib2swagger.js +44 -18
- package/index.js +82 -366
- package/package.json +6 -4
- package/src/escape_json_pointer.js +0 -0
- package/src/mson_to_json_schema.js +13 -8
- package/src/parameters.js +111 -0
- package/src/requests.js +344 -0
- package/src/responses.js +181 -0
- package/src/util.js +127 -0
- package/test/input/Attributes.md +0 -0
- package/test/input/Issue-#15.md +0 -0
- package/test/input/Issue-#22.md +0 -0
- package/test/input/Issue-#23.md +0 -0
- package/test/input/Issue-#26.md +0 -0
- package/test/input/Issue-#29.md +0 -0
- package/test/input/Issue-#33.md +0 -0
- package/test/input/Issue-#35.md +0 -0
- package/test/input/Issue-#36.md +0 -0
- package/test/input/Issue-#38.md +0 -0
- package/test/input/Issue-#49.md +24 -0
- package/test/input/OpenAPI3_attributes.md +36 -0
- package/test/input/OpenAPI3_headers.md +74 -0
- package/test/input/OpenAPI3_includes.md +22 -0
- package/test/input/OpenAPI3_requests.md +162 -0
- package/test/input/OpenAPI3_responses.md +177 -0
- package/test/input/Schema.md +0 -0
- package/test/input/apiblueprint_uber.md +0 -0
- package/test/input/apiblueprint_valid_simple.md +0 -0
- package/test/input/includes/resource-request-body-2.json +3 -0
- package/test/input/includes/resource-request-body.json +3 -0
- package/test/input/includes/resource-request-schema.json +9 -0
- package/test/input/includes/resource-response-body-2.json +3 -0
- package/test/input/includes/resource-response-body.json +3 -0
- package/test/input/includes/resource-response-schema.json +9 -0
- package/test/input/schema_without_body.md +17 -0
- package/test/meta_schema.json +0 -0
- package/test/openAPI_30_schema.json +1662 -0
- package/test/output/01. Simplest API.json +1 -0
- package/test/output/01. Simplest API.ref.json +1 -0
- package/test/output/02. Resource and Actions.json +2 -0
- package/test/output/02. Resource and Actions.ref.json +2 -0
- package/test/output/03. Named Resource and Actions.json +2 -0
- package/test/output/03. Named Resource and Actions.ref.json +2 -0
- package/test/output/04. Grouping Resources.json +2 -0
- package/test/output/04. Grouping Resources.ref.json +2 -0
- package/test/output/05. Responses.json +2 -0
- package/test/output/05. Responses.ref.json +2 -0
- package/test/output/06. Requests.json +2 -0
- package/test/output/06. Requests.ref.json +2 -0
- package/test/output/07. Parameters.json +3 -0
- package/test/output/07. Parameters.ref.json +3 -0
- package/test/output/08. Attributes.json +1 -0
- package/test/output/08. Attributes.ref.json +1 -0
- package/test/output/09. Advanced Attributes.json +3 -0
- package/test/output/09. Advanced Attributes.ref.json +3 -0
- package/test/output/10. Data Structures.json +3 -0
- package/test/output/10. Data Structures.ref.json +3 -0
- package/test/output/11. Resource Model.json +2 -0
- package/test/output/11. Resource Model.ref.json +2 -0
- package/test/output/12. Advanced Action.json +3 -0
- package/test/output/12. Advanced Action.ref.json +3 -0
- package/test/output/13. Named Endpoints.json +2 -0
- package/test/output/13. Named Endpoints.ref.json +2 -0
- package/test/output/Attributes.json +1 -0
- package/test/output/Attributes.ref.json +1 -0
- package/test/output/Gist Fox API + Auth.json +12 -0
- package/test/output/Gist Fox API + Auth.ref.json +12 -0
- package/test/output/Issue-#15.json +3 -0
- package/test/output/Issue-#15.ref.json +3 -0
- package/test/output/Issue-#22.json +0 -0
- package/test/output/Issue-#22.ref.json +0 -0
- package/test/output/Issue-#23.json +1 -0
- package/test/output/Issue-#23.ref.json +1 -0
- package/test/output/Issue-#26.json +2 -0
- package/test/output/Issue-#26.ref.json +2 -0
- package/test/output/Issue-#29.json +2 -0
- package/test/output/Issue-#29.ref.json +2 -0
- package/test/output/Issue-#33.json +9 -8
- package/test/output/Issue-#33.ref.json +9 -8
- package/test/output/Issue-#35.json +0 -0
- package/test/output/Issue-#35.ref.json +0 -0
- package/test/output/Issue-#36.json +1 -0
- package/test/output/Issue-#36.ref.json +1 -0
- package/test/output/Issue-#38.bearer.json +53 -52
- package/test/output/Issue-#38.json +1 -0
- package/test/output/Issue-#38.ref.json +1 -0
- package/test/output/Issue-#49.json +141 -0
- package/test/output/Issue-#49.ref.json +126 -0
- package/test/output/OpenAPI3_attributes.json +199 -0
- package/test/output/OpenAPI3_attributes.ref.json +173 -0
- package/test/output/OpenAPI3_headers.json +169 -0
- package/test/output/OpenAPI3_headers.ref.json +169 -0
- package/test/output/OpenAPI3_includes.json +66 -0
- package/test/output/OpenAPI3_includes.ref.json +66 -0
- package/test/output/OpenAPI3_requests.json +326 -0
- package/test/output/OpenAPI3_requests.ref.json +321 -0
- package/test/output/OpenAPI3_responses.json +255 -0
- package/test/output/OpenAPI3_responses.ref.json +245 -0
- package/test/output/Schema.json +3 -0
- package/test/output/Schema.ref.json +3 -0
- package/test/output/apiblueprint_uber.json +5 -0
- package/test/output/apiblueprint_uber.ref.json +5 -0
- package/test/output/apiblueprint_valid_simple.json +12 -0
- package/test/output/apiblueprint_valid_simple.ref.json +12 -0
- package/test/output/schema_without_body.json +52 -0
- package/test/output/schema_without_body.ref.json +52 -0
- package/test/swagger_20_schema.json +0 -0
- package/test/test.js +31 -15
- package/test/util.test.js +151 -0
- package/.npmignore +0 -35
- package/package-lock.json +0 -2320
package/src/util.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const jsonSchemaFromMSON = require('./mson_to_json_schema')
|
|
2
|
+
const GenerateSchema = require('generate-schema')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
|
|
6
|
+
module.exports.hasFileRef = (section) => section
|
|
7
|
+
.replace(/\s+/g, '') // remove spaces
|
|
8
|
+
.includes('<!--include')
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
Takes a string with many includes and normalizes all of the includes so that the contents
|
|
12
|
+
can be imported or references to files can be created properly.
|
|
13
|
+
Includes input formats
|
|
14
|
+
<!-- include: path/to/file -->
|
|
15
|
+
<!-- include(path/to/file) -->
|
|
16
|
+
<!-- include(path/to/file -->
|
|
17
|
+
Includes output format <!-- include(path/to/file) -->
|
|
18
|
+
*/
|
|
19
|
+
module.exports.normalizeIncludes = (str) => str
|
|
20
|
+
.split('<!-- include')
|
|
21
|
+
.map((s, i) => {
|
|
22
|
+
if (i === 0) {
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
let include = s
|
|
26
|
+
.substr(0, s.indexOf('-->'))
|
|
27
|
+
.trim()
|
|
28
|
+
|
|
29
|
+
if (include.slice(-1) === ')'){
|
|
30
|
+
include = include.substr(0, include.length - 1)
|
|
31
|
+
}
|
|
32
|
+
if (include.slice(0, 1) === '(' || include.slice(0, 1) === ':'){
|
|
33
|
+
include = include.substr(1, include.length)
|
|
34
|
+
}
|
|
35
|
+
const restOfStr = s.substr(s.indexOf('-->') + 3, s.length)
|
|
36
|
+
return include.trim() + ') -->' + restOfStr
|
|
37
|
+
})
|
|
38
|
+
.join('<!-- include(');
|
|
39
|
+
|
|
40
|
+
// Return a reference object to the file path from the include statement.
|
|
41
|
+
// Even though includes should now be normalized, this handles a scenario where they may not be.
|
|
42
|
+
module.exports.getRefFromInclude = (include) => {
|
|
43
|
+
let path = include.replace(/\s+/g, '')
|
|
44
|
+
if (path.includes('include(') && path.includes('-->')) {
|
|
45
|
+
path = path.substring(
|
|
46
|
+
path.indexOf('(') + 1,
|
|
47
|
+
path.indexOf('-->')
|
|
48
|
+
)
|
|
49
|
+
// the closing paren is optional so we remove it if it is there.
|
|
50
|
+
const lastChar = path.slice(-1)
|
|
51
|
+
if (lastChar === ')'){
|
|
52
|
+
path = path.substring(0, path.length - 1)
|
|
53
|
+
}
|
|
54
|
+
} else if (path.includes('include:') && path.includes('-->')) {
|
|
55
|
+
path = path.substring(
|
|
56
|
+
path.indexOf(':') + 1,
|
|
57
|
+
path.indexOf('-->')
|
|
58
|
+
)
|
|
59
|
+
} else {
|
|
60
|
+
throw Error('Invalid include syntax:' + include)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { $ref: path }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports.searchDataStructure = function (contents, options) {
|
|
67
|
+
for (var i = 0; i < contents.length; i++) {
|
|
68
|
+
var content = contents[i];
|
|
69
|
+
if (content.element !== "dataStructure") continue;
|
|
70
|
+
return jsonSchemaFromMSON(content, options);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports.generateSchemaFromExample = function (headers, example, options) {
|
|
75
|
+
if (!headers || !headers.some(header => (
|
|
76
|
+
header.name === 'Content-Type' && header.value.match(/application\/.*json/)
|
|
77
|
+
))) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const body = JSON.parse(example);
|
|
82
|
+
const scheme = GenerateSchema.json("", body);
|
|
83
|
+
if (!scheme) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
delete scheme.title;
|
|
87
|
+
delete scheme.$schema;
|
|
88
|
+
// if we have example values in the body then insert them into the json schema
|
|
89
|
+
if (!options.openApi3) {
|
|
90
|
+
if (scheme['type'] === 'object') {
|
|
91
|
+
scheme.example = body;
|
|
92
|
+
} else if (scheme['type'] === 'array') {
|
|
93
|
+
scheme.items.example = body;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return scheme;
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const fixArraySchema = function (schema) {
|
|
103
|
+
if (schema.type === 'array') {
|
|
104
|
+
if (!schema.hasOwnProperty('items')) schema.items = {};
|
|
105
|
+
} else if (schema.type === 'object') {
|
|
106
|
+
for (var k in schema.properties) fixArraySchema(schema.properties[k]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
module.exports.fixArraySchema = fixArraySchema
|
|
110
|
+
|
|
111
|
+
module.exports.getAbsolutePath = function (options, filePath) {
|
|
112
|
+
const sd = options['source-dir']
|
|
113
|
+
const directory = sd ? path.normalize(sd) : null
|
|
114
|
+
let absolutePath
|
|
115
|
+
if (directory) {
|
|
116
|
+
absolutePath = path.join(directory, filePath) // Try given (source-dir) directory
|
|
117
|
+
if (fs.existsSync(absolutePath)) return absolutePath
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
absolutePath = path.join(process.cwd(), filePath) // Try execution location's directory
|
|
121
|
+
if (fs.existsSync(absolutePath)) return absolutePath
|
|
122
|
+
|
|
123
|
+
absolutePath = path.join(path.dirname(options.input || ''), filePath) // Try input file's directory
|
|
124
|
+
if (fs.existsSync(absolutePath)) return absolutePath
|
|
125
|
+
|
|
126
|
+
return null
|
|
127
|
+
}
|
package/test/input/Attributes.md
CHANGED
|
File without changes
|
package/test/input/Issue-#15.md
CHANGED
|
File without changes
|
package/test/input/Issue-#22.md
CHANGED
|
File without changes
|
package/test/input/Issue-#23.md
CHANGED
|
File without changes
|
package/test/input/Issue-#26.md
CHANGED
|
File without changes
|
package/test/input/Issue-#29.md
CHANGED
|
File without changes
|
package/test/input/Issue-#33.md
CHANGED
|
File without changes
|
package/test/input/Issue-#35.md
CHANGED
|
File without changes
|
package/test/input/Issue-#36.md
CHANGED
|
File without changes
|
package/test/input/Issue-#38.md
CHANGED
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Group Users
|
|
2
|
+
|
|
3
|
+
## A user [/user]
|
|
4
|
+
|
|
5
|
+
### Get one user [GET]
|
|
6
|
+
+ Response 200 (application/json)
|
|
7
|
+
+ Attributes (User)
|
|
8
|
+
+ Response 500 (application/json)
|
|
9
|
+
|
|
10
|
+
## Some users [/users]
|
|
11
|
+
|
|
12
|
+
### Get a collection of users [GET]
|
|
13
|
+
+ Response 200 (application/json)
|
|
14
|
+
+ Attributes (array[User])
|
|
15
|
+
+ Response 500 (application/json)
|
|
16
|
+
|
|
17
|
+
# Data Structures
|
|
18
|
+
|
|
19
|
+
## User (object)
|
|
20
|
+
+ id (string, required)
|
|
21
|
+
+ name (string, nullable, required)
|
|
22
|
+
|
|
23
|
+
## Users (object)
|
|
24
|
+
+ `users`(array[User], nullable, required)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
HOST: https://www.testhost.com
|
|
2
|
+
|
|
3
|
+
# Some resource [GET /object]
|
|
4
|
+
+ Request (application/json)
|
|
5
|
+
|
|
6
|
+
+ Response 200 (application/json)
|
|
7
|
+
+ Attributes (object)
|
|
8
|
+
+ message (string)
|
|
9
|
+
|
|
10
|
+
+ Response 200 (application/json)
|
|
11
|
+
+ Attributes (OtherMessage)
|
|
12
|
+
|
|
13
|
+
# Some resource [POST /array/object]
|
|
14
|
+
+ Request (application/json)
|
|
15
|
+
+ Attributes (Message)
|
|
16
|
+
|
|
17
|
+
+ Response 200 (application/json)
|
|
18
|
+
+ Attributes (array, fixed-type)
|
|
19
|
+
+ (object)
|
|
20
|
+
+ path: `/files` (required)
|
|
21
|
+
+ otherMessage (OtherMessage)
|
|
22
|
+
|
|
23
|
+
# Some resource [GET /messages]
|
|
24
|
+
+ Request (application/json)
|
|
25
|
+
|
|
26
|
+
+ Response 200 (application/json)
|
|
27
|
+
+ Attributes (array[Message], fixed-type)
|
|
28
|
+
|
|
29
|
+
## Data structures
|
|
30
|
+
|
|
31
|
+
# Message
|
|
32
|
+
- message (string)
|
|
33
|
+
|
|
34
|
+
# OtherMessage
|
|
35
|
+
- otherMessage (string)
|
|
36
|
+
- someNum (number)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
HOST: https://www.testhost.com
|
|
2
|
+
|
|
3
|
+
# Some resource [POST /some/resource]
|
|
4
|
+
+ Request (application/json)
|
|
5
|
+
+ Header
|
|
6
|
+
x-testhost-auth-sign: signed body
|
|
7
|
+
|
|
8
|
+
+ Header
|
|
9
|
+
Authorization: Bearer Admin
|
|
10
|
+
|
|
11
|
+
+ Header
|
|
12
|
+
Authorization: Bearer User
|
|
13
|
+
|
|
14
|
+
+ Schema
|
|
15
|
+
{
|
|
16
|
+
"type": "object",
|
|
17
|
+
"properties": {
|
|
18
|
+
"someType": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
+ Request (application/json)
|
|
25
|
+
+ Header
|
|
26
|
+
x-testhost-auth-sign: signed body
|
|
27
|
+
|
|
28
|
+
+ Header
|
|
29
|
+
Authorization: Bearer Admin
|
|
30
|
+
|
|
31
|
+
+ Header
|
|
32
|
+
Authorization: Bearer User
|
|
33
|
+
|
|
34
|
+
+ Schema
|
|
35
|
+
{
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"someType": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
+ Response 200
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Restricted resource [GET /some/restricted/resource]
|
|
48
|
+
Has a duplicate header within a single declaration
|
|
49
|
+
+ Request (application/json)
|
|
50
|
+
+ Header
|
|
51
|
+
Authorization: Bearer Admin
|
|
52
|
+
Authorization: Bearer Admin
|
|
53
|
+
|
|
54
|
+
+ Schema
|
|
55
|
+
{
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"message1": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "This is the message description "
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
+ Response 200
|
|
66
|
+
|
|
67
|
+
# Additional resource [GET /additional/resource]
|
|
68
|
+
+ Request (application/json)
|
|
69
|
+
+ Header
|
|
70
|
+
x-testhost-auth-sign: signed body
|
|
71
|
+
Authorization: Bearer Admin
|
|
72
|
+
Authorization: Bearer User
|
|
73
|
+
|
|
74
|
+
+ Response 200
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
HOST: https://www.testhost.com
|
|
2
|
+
|
|
3
|
+
# Some resource [GET /some/resource]
|
|
4
|
+
+ Request (application/json)
|
|
5
|
+
+ Body
|
|
6
|
+
<!-- include(./includes/resource-request-body.json) -->
|
|
7
|
+
+ Schema
|
|
8
|
+
<!-- include(./includes/resource-request-schema.json -->
|
|
9
|
+
|
|
10
|
+
+ Request (application/json)
|
|
11
|
+
+ Body
|
|
12
|
+
<!-- include(./includes/resource-request-body-2.json) -->
|
|
13
|
+
|
|
14
|
+
+ Response 200 (application/json)
|
|
15
|
+
+ Body
|
|
16
|
+
<!-- include: ./includes/resource-response-body.json -->
|
|
17
|
+
+ Schema
|
|
18
|
+
<!-- include: ./includes/resource-response-schema.json -->
|
|
19
|
+
|
|
20
|
+
+ Response 200 (application/json)
|
|
21
|
+
+ Body
|
|
22
|
+
<!-- include ( ./includes/resource-response-body-2.json -->
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
HOST: https://www.testhost.com
|
|
2
|
+
|
|
3
|
+
# Some resource [GET /some/resource/{pathParam}{?queryParam}]
|
|
4
|
+
+ Parameters
|
|
5
|
+
+ pathParam: exampleValue (required, string)
|
|
6
|
+
+ Default: defaultValue
|
|
7
|
+
+ queryParam: value1 (required, enum[string])
|
|
8
|
+
+ Members
|
|
9
|
+
+ value1
|
|
10
|
+
+ value2
|
|
11
|
+
+ additionalQueryParam (string)
|
|
12
|
+
|
|
13
|
+
+ Request (application/json)
|
|
14
|
+
+ Schema
|
|
15
|
+
{
|
|
16
|
+
"type": "object",
|
|
17
|
+
"properties": {
|
|
18
|
+
"message1": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "This is the message description "
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
+ Request
|
|
26
|
+
+ Schema
|
|
27
|
+
{
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"message2": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "This is the message description "
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
+ Request
|
|
38
|
+
+ Schema
|
|
39
|
+
{
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"message3": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "This is the message description "
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
+ Request
|
|
50
|
+
duplicate
|
|
51
|
+
+ Schema
|
|
52
|
+
{
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"message1": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "This is the message description "
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
+ Response 200 (application/json)
|
|
63
|
+
|
|
64
|
+
# Another resource [GET /another/resource/]
|
|
65
|
+
+ Request (application/json)
|
|
66
|
+
+ Schema
|
|
67
|
+
{
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": {
|
|
70
|
+
"message1": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "This is the message description "
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
+ Body
|
|
78
|
+
{
|
|
79
|
+
"message1": "Hello world"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
+ Request (application/json)
|
|
83
|
+
+ Schema
|
|
84
|
+
{
|
|
85
|
+
"type": "object",
|
|
86
|
+
"properties": {
|
|
87
|
+
"message2": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"description": "This is the message description "
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
+ Body
|
|
95
|
+
{
|
|
96
|
+
"message2": "Hello world"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
+ Response 200 (application/json)
|
|
100
|
+
|
|
101
|
+
# Some resource [GET /withAttributes]
|
|
102
|
+
+ Request (application/json)
|
|
103
|
+
+ Schema
|
|
104
|
+
{
|
|
105
|
+
"type": "object",
|
|
106
|
+
"properties": {
|
|
107
|
+
"someType": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"description": "This is the message description "
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
+ Request (application/json)
|
|
115
|
+
+ Attributes (Message)
|
|
116
|
+
|
|
117
|
+
+ Response 200 (application/json)
|
|
118
|
+
|
|
119
|
+
# Some resource [GET /onlyAttributes]
|
|
120
|
+
+ Attributes (Message)
|
|
121
|
+
|
|
122
|
+
+ Response 200 (application/json)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# Some resource [GET /onlyExamples]
|
|
126
|
+
+ Request (application/json)
|
|
127
|
+
+ Body
|
|
128
|
+
{
|
|
129
|
+
"message": "test1"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
+ Request (application/json)
|
|
133
|
+
+ Body
|
|
134
|
+
{
|
|
135
|
+
"message": "test2"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
+ Request (application/json)
|
|
139
|
+
+ Body
|
|
140
|
+
{
|
|
141
|
+
"message": "test3"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
+ Request (text/plain)
|
|
145
|
+
+ Body
|
|
146
|
+
test
|
|
147
|
+
|
|
148
|
+
+ Response 200 (application/json)
|
|
149
|
+
|
|
150
|
+
# Some resource [GET /bodyOnly]
|
|
151
|
+
+ Request (application/json)
|
|
152
|
+
+ Body
|
|
153
|
+
{
|
|
154
|
+
"message": "test2"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
+ Response 200 (application/json)
|
|
158
|
+
|
|
159
|
+
## Data structures
|
|
160
|
+
|
|
161
|
+
# Message
|
|
162
|
+
- message (string)
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
HOST: https://www.testhost.com
|
|
2
|
+
|
|
3
|
+
# Some resource [GET /some/resource]
|
|
4
|
+
|
|
5
|
+
+ Request
|
|
6
|
+
|
|
7
|
+
+ Response 200 (application/json)
|
|
8
|
+
+ Headers
|
|
9
|
+
X-My-Message-Header: 42
|
|
10
|
+
|
|
11
|
+
+ Body
|
|
12
|
+
{
|
|
13
|
+
"message": "Hello World!"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
+ Schema
|
|
17
|
+
{
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"message": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "This is the message description "
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
+ Response 200 (application/json)
|
|
29
|
+
Unique schema
|
|
30
|
+
|
|
31
|
+
+ Headers
|
|
32
|
+
X-My-Message-Header: 42
|
|
33
|
+
|
|
34
|
+
+ Body
|
|
35
|
+
{ "other": "Hello World!" }
|
|
36
|
+
|
|
37
|
+
+ Schema
|
|
38
|
+
{
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"other": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "This is the message description "
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
+ Response 200 (application/json)
|
|
49
|
+
Duplicate Schema
|
|
50
|
+
|
|
51
|
+
+ Headers
|
|
52
|
+
X-My-Message-Header: 42
|
|
53
|
+
|
|
54
|
+
+ Body
|
|
55
|
+
{ "other": "Hello World!" }
|
|
56
|
+
|
|
57
|
+
+ Schema
|
|
58
|
+
{
|
|
59
|
+
"type": "object",
|
|
60
|
+
"properties": {
|
|
61
|
+
"message": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"description": "This is the message description "
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
+ Response 200 (application/json)
|
|
69
|
+
Array schema
|
|
70
|
+
|
|
71
|
+
+ Headers
|
|
72
|
+
X-My-Message-Header: 42
|
|
73
|
+
|
|
74
|
+
+ Body
|
|
75
|
+
[{ "message": "Hello World!" }]
|
|
76
|
+
|
|
77
|
+
+ Schema
|
|
78
|
+
{
|
|
79
|
+
"type": "array",
|
|
80
|
+
"items": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"properties": {
|
|
83
|
+
"message": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"description": "This is the message description "
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
+ Response 400 (application/json)
|
|
93
|
+
+ Body
|
|
94
|
+
{ "message": "Invalid data" }
|
|
95
|
+
|
|
96
|
+
# Some resource [POST /some/resource]
|
|
97
|
+
|
|
98
|
+
+ Request
|
|
99
|
+
|
|
100
|
+
+ Response 200 (application/json)
|
|
101
|
+
+ Headers
|
|
102
|
+
X-My-Message-Header: 42
|
|
103
|
+
|
|
104
|
+
+ Body
|
|
105
|
+
{
|
|
106
|
+
"message": "Hello World!"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
+ Schema
|
|
110
|
+
{
|
|
111
|
+
"type": "object",
|
|
112
|
+
"properties": {
|
|
113
|
+
"message": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"description": "This is the message description "
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
+ Response 200 (application/json)
|
|
122
|
+
+ Headers
|
|
123
|
+
X-My-Message-Header: 42
|
|
124
|
+
|
|
125
|
+
+ Body
|
|
126
|
+
{ "message": "Hello World!" }
|
|
127
|
+
|
|
128
|
+
+ Schema
|
|
129
|
+
{
|
|
130
|
+
"type": "object",
|
|
131
|
+
"properties": {
|
|
132
|
+
"message": {
|
|
133
|
+
"type": "string",
|
|
134
|
+
"description": "This is the message description "
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# Some resource [GET /test/attributes]
|
|
140
|
+
|
|
141
|
+
- Request
|
|
142
|
+
|
|
143
|
+
- Response 200 (application/json)
|
|
144
|
+
- Body
|
|
145
|
+
{ "message": "Hello World!" }
|
|
146
|
+
|
|
147
|
+
- Attributes (Message)
|
|
148
|
+
|
|
149
|
+
- Response 200 (application/json)
|
|
150
|
+
- Body
|
|
151
|
+
{ "message": "Hello World2" }
|
|
152
|
+
|
|
153
|
+
- Attributes (Message)
|
|
154
|
+
|
|
155
|
+
- Response 200 (application/json)
|
|
156
|
+
- Body
|
|
157
|
+
{ "otherMessage": "Hello World!" }
|
|
158
|
+
|
|
159
|
+
- Attributes (OtherMessage)
|
|
160
|
+
|
|
161
|
+
# Message [GET /message]
|
|
162
|
+
|
|
163
|
+
+ Response 200 (application/json)
|
|
164
|
+
Unparsable schema should fall back to Attributes
|
|
165
|
+
|
|
166
|
+
+ Schema
|
|
167
|
+
{1234{}I'm unparsable}
|
|
168
|
+
|
|
169
|
+
+ Attributes (Message)
|
|
170
|
+
|
|
171
|
+
## Data structures
|
|
172
|
+
|
|
173
|
+
# Message
|
|
174
|
+
- message (string)
|
|
175
|
+
|
|
176
|
+
# OtherMessage
|
|
177
|
+
- otherMessage (string)
|
package/test/input/Schema.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|