apib2swagger 1.15.0 → 1.16.1
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/nodejs.yml +1 -1
- package/.travis.yml +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/mson_to_json_schema.js +1 -0
- package/src/responses.js +7 -1
- package/test/input/Issue-#35.md +6 -0
- package/test/output/05. Responses.json +11 -0
- package/test/output/05. Responses.ref.json +11 -0
- package/test/output/06. Requests.json +11 -0
- package/test/output/06. Requests.ref.json +11 -0
- package/test/output/07. Parameters.json +47 -0
- package/test/output/07. Parameters.ref.json +47 -0
- package/test/output/12. Advanced Action.json +63 -0
- package/test/output/12. Advanced Action.ref.json +63 -0
- package/test/output/Gist Fox API + Auth.json +51 -0
- package/test/output/Gist Fox API + Auth.ref.json +51 -0
- package/test/output/Issue-#35.json +9 -0
- package/test/output/Issue-#35.ref.json +9 -0
- package/test/output/OpenAPI3_responses.json +240 -232
- package/test/output/OpenAPI3_responses.ref.json +231 -223
- package/test/output/Schema.json +11 -0
- package/test/output/Schema.ref.json +11 -0
- package/test/output/apiblueprint_valid_simple.json +51 -0
- package/test/output/apiblueprint_valid_simple.ref.json +51 -0
package/.travis.yml
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
package/src/responses.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { fixArraySchema, hasFileRef, getRefFromInclude, searchDataStructure } = require('./util')
|
|
1
|
+
const { fixArraySchema, hasFileRef, getRefFromInclude, searchDataStructure, generateSchemaFromExample } = require('./util')
|
|
2
2
|
const escapeJSONPointer = require('./escape_json_pointer')
|
|
3
3
|
const isEqual = require('lodash.isequal')
|
|
4
4
|
const http = require('http')
|
|
@@ -58,6 +58,12 @@ const getResponseSchema = (response, options) => {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
for (let content of response.content) {
|
|
62
|
+
const schema = generateSchemaFromExample(response.headers, content.content, options)
|
|
63
|
+
if (schema) {
|
|
64
|
+
return schema
|
|
65
|
+
}
|
|
66
|
+
}
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
const setResponseSchema = (responses, response, schema, options) => {
|
package/test/input/Issue-#35.md
CHANGED
|
@@ -21,6 +21,21 @@
|
|
|
21
21
|
"id": 1,
|
|
22
22
|
"message": "Hello World!"
|
|
23
23
|
}
|
|
24
|
+
},
|
|
25
|
+
"schema": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"id": {
|
|
29
|
+
"type": "number"
|
|
30
|
+
},
|
|
31
|
+
"message": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"example": {
|
|
36
|
+
"id": 1,
|
|
37
|
+
"message": "Hello World!"
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
}
|
|
26
41
|
},
|
|
@@ -114,6 +129,38 @@
|
|
|
114
129
|
"message": "So long, and thanks for all the fish."
|
|
115
130
|
}
|
|
116
131
|
]
|
|
132
|
+
},
|
|
133
|
+
"schema": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"id": {
|
|
139
|
+
"type": "number"
|
|
140
|
+
},
|
|
141
|
+
"message": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"required": [
|
|
146
|
+
"id",
|
|
147
|
+
"message"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"example": [
|
|
151
|
+
{
|
|
152
|
+
"id": 1,
|
|
153
|
+
"message": "Hello World!"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": 2,
|
|
157
|
+
"message": "Time is an illusion. Lunchtime doubly so."
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"id": 3,
|
|
161
|
+
"message": "So long, and thanks for all the fish."
|
|
162
|
+
}
|
|
163
|
+
]
|
|
117
164
|
}
|
|
118
165
|
}
|
|
119
166
|
},
|
|
@@ -21,6 +21,21 @@
|
|
|
21
21
|
"id": 1,
|
|
22
22
|
"message": "Hello World!"
|
|
23
23
|
}
|
|
24
|
+
},
|
|
25
|
+
"schema": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"id": {
|
|
29
|
+
"type": "number"
|
|
30
|
+
},
|
|
31
|
+
"message": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"example": {
|
|
36
|
+
"id": 1,
|
|
37
|
+
"message": "Hello World!"
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
}
|
|
26
41
|
},
|
|
@@ -114,6 +129,38 @@
|
|
|
114
129
|
"message": "So long, and thanks for all the fish."
|
|
115
130
|
}
|
|
116
131
|
]
|
|
132
|
+
},
|
|
133
|
+
"schema": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"id": {
|
|
139
|
+
"type": "number"
|
|
140
|
+
},
|
|
141
|
+
"message": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"required": [
|
|
146
|
+
"id",
|
|
147
|
+
"message"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"example": [
|
|
151
|
+
{
|
|
152
|
+
"id": 1,
|
|
153
|
+
"message": "Hello World!"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": 2,
|
|
157
|
+
"message": "Time is an illusion. Lunchtime doubly so."
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"id": 3,
|
|
161
|
+
"message": "So long, and thanks for all the fish."
|
|
162
|
+
}
|
|
163
|
+
]
|
|
117
164
|
}
|
|
118
165
|
}
|
|
119
166
|
},
|
|
@@ -27,6 +27,46 @@
|
|
|
27
27
|
"type": "task"
|
|
28
28
|
}
|
|
29
29
|
]
|
|
30
|
+
},
|
|
31
|
+
"schema": {
|
|
32
|
+
"type": "array",
|
|
33
|
+
"items": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": {
|
|
36
|
+
"id": {
|
|
37
|
+
"type": "number"
|
|
38
|
+
},
|
|
39
|
+
"name": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
},
|
|
42
|
+
"done": {
|
|
43
|
+
"type": "boolean"
|
|
44
|
+
},
|
|
45
|
+
"type": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": [
|
|
50
|
+
"id",
|
|
51
|
+
"name",
|
|
52
|
+
"done",
|
|
53
|
+
"type"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"example": [
|
|
57
|
+
{
|
|
58
|
+
"id": 123,
|
|
59
|
+
"name": "Exercise in gym",
|
|
60
|
+
"done": false,
|
|
61
|
+
"type": "task"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": 124,
|
|
65
|
+
"name": "Shop for groceries",
|
|
66
|
+
"done": true,
|
|
67
|
+
"type": "task"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
30
70
|
}
|
|
31
71
|
}
|
|
32
72
|
},
|
|
@@ -68,6 +108,29 @@
|
|
|
68
108
|
"done": false,
|
|
69
109
|
"type": "task"
|
|
70
110
|
}
|
|
111
|
+
},
|
|
112
|
+
"schema": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"properties": {
|
|
115
|
+
"id": {
|
|
116
|
+
"type": "number"
|
|
117
|
+
},
|
|
118
|
+
"name": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
},
|
|
121
|
+
"done": {
|
|
122
|
+
"type": "boolean"
|
|
123
|
+
},
|
|
124
|
+
"type": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"example": {
|
|
129
|
+
"id": 123,
|
|
130
|
+
"name": "Go to gym",
|
|
131
|
+
"done": false,
|
|
132
|
+
"type": "task"
|
|
133
|
+
}
|
|
71
134
|
}
|
|
72
135
|
}
|
|
73
136
|
},
|
|
@@ -27,6 +27,46 @@
|
|
|
27
27
|
"type": "task"
|
|
28
28
|
}
|
|
29
29
|
]
|
|
30
|
+
},
|
|
31
|
+
"schema": {
|
|
32
|
+
"type": "array",
|
|
33
|
+
"items": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": {
|
|
36
|
+
"id": {
|
|
37
|
+
"type": "number"
|
|
38
|
+
},
|
|
39
|
+
"name": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
},
|
|
42
|
+
"done": {
|
|
43
|
+
"type": "boolean"
|
|
44
|
+
},
|
|
45
|
+
"type": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": [
|
|
50
|
+
"id",
|
|
51
|
+
"name",
|
|
52
|
+
"done",
|
|
53
|
+
"type"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"example": [
|
|
57
|
+
{
|
|
58
|
+
"id": 123,
|
|
59
|
+
"name": "Exercise in gym",
|
|
60
|
+
"done": false,
|
|
61
|
+
"type": "task"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": 124,
|
|
65
|
+
"name": "Shop for groceries",
|
|
66
|
+
"done": true,
|
|
67
|
+
"type": "task"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
30
70
|
}
|
|
31
71
|
}
|
|
32
72
|
},
|
|
@@ -68,6 +108,29 @@
|
|
|
68
108
|
"done": false,
|
|
69
109
|
"type": "task"
|
|
70
110
|
}
|
|
111
|
+
},
|
|
112
|
+
"schema": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"properties": {
|
|
115
|
+
"id": {
|
|
116
|
+
"type": "number"
|
|
117
|
+
},
|
|
118
|
+
"name": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
},
|
|
121
|
+
"done": {
|
|
122
|
+
"type": "boolean"
|
|
123
|
+
},
|
|
124
|
+
"type": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"example": {
|
|
129
|
+
"id": 123,
|
|
130
|
+
"name": "Go to gym",
|
|
131
|
+
"done": false,
|
|
132
|
+
"type": "task"
|
|
133
|
+
}
|
|
71
134
|
}
|
|
72
135
|
}
|
|
73
136
|
},
|
|
@@ -31,6 +31,57 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
},
|
|
35
|
+
"schema": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"_links": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"self": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"href": {
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"gists": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"properties": {
|
|
52
|
+
"href": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"templated": {
|
|
56
|
+
"type": "boolean"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"authorization": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"href": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"example": {
|
|
72
|
+
"_links": {
|
|
73
|
+
"self": {
|
|
74
|
+
"href": "/"
|
|
75
|
+
},
|
|
76
|
+
"gists": {
|
|
77
|
+
"href": "/gists?{since}",
|
|
78
|
+
"templated": true
|
|
79
|
+
},
|
|
80
|
+
"authorization": {
|
|
81
|
+
"href": "/authorization"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
34
85
|
}
|
|
35
86
|
}
|
|
36
87
|
},
|
|
@@ -31,6 +31,57 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
},
|
|
35
|
+
"schema": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"_links": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"self": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"href": {
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"gists": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"properties": {
|
|
52
|
+
"href": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"templated": {
|
|
56
|
+
"type": "boolean"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"authorization": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"href": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"example": {
|
|
72
|
+
"_links": {
|
|
73
|
+
"self": {
|
|
74
|
+
"href": "/"
|
|
75
|
+
},
|
|
76
|
+
"gists": {
|
|
77
|
+
"href": "/gists?{since}",
|
|
78
|
+
"templated": true
|
|
79
|
+
},
|
|
80
|
+
"authorization": {
|
|
81
|
+
"href": "/authorization"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
34
85
|
}
|
|
35
86
|
}
|
|
36
87
|
},
|