apib2swagger 1.9.2 → 1.13.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 +3 -5
- package/Dockerfile +5 -0
- package/LICENSE +0 -0
- package/README.md +31 -5
- package/bin/apib2swagger.js +43 -17
- package/index.js +92 -374
- 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 +7 -1
- package/test/output/05. Responses.ref.json +7 -1
- package/test/output/06. Requests.json +9 -3
- package/test/output/06. Requests.ref.json +9 -3
- package/test/output/07. Parameters.json +12 -5
- package/test/output/07. Parameters.ref.json +12 -5
- 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 +7 -1
- package/test/output/11. Resource Model.ref.json +7 -1
- 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 +12 -2
- package/test/output/13. Named Endpoints.ref.json +12 -2
- package/test/output/Attributes.json +1 -0
- package/test/output/Attributes.ref.json +1 -0
- package/test/output/Gist Fox API + Auth.json +47 -7
- package/test/output/Gist Fox API + Auth.ref.json +47 -7
- 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 +47 -7
- package/test/output/apiblueprint_valid_simple.ref.json +47 -7
- 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
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"responses": {
|
|
12
12
|
"200": {
|
|
13
13
|
"description": "OK",
|
|
14
|
-
"headers": {
|
|
14
|
+
"headers": {
|
|
15
|
+
"Link": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
15
19
|
"examples": {
|
|
16
20
|
"application/hal+json": {
|
|
17
21
|
"_links": {
|
|
@@ -31,6 +35,7 @@
|
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"summary": "Retrieve the Entry Point",
|
|
38
|
+
"operationId": "Retrieve the Entry Point",
|
|
34
39
|
"description": "",
|
|
35
40
|
"tags": [],
|
|
36
41
|
"parameters": [],
|
|
@@ -44,7 +49,11 @@
|
|
|
44
49
|
"responses": {
|
|
45
50
|
"200": {
|
|
46
51
|
"description": "HAL+JSON representation of Gist Resource. In addition to representing its state in the JSON form it offers affordances in the form of the HTTP Link header and HAL links.",
|
|
47
|
-
"headers": {
|
|
52
|
+
"headers": {
|
|
53
|
+
"Link": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
48
57
|
"examples": {},
|
|
49
58
|
"schema": {
|
|
50
59
|
"$ref": "#/definitions/GistModel"
|
|
@@ -52,6 +61,7 @@
|
|
|
52
61
|
}
|
|
53
62
|
},
|
|
54
63
|
"summary": "Retrieve a Single Gist",
|
|
64
|
+
"operationId": "Retrieve a Single Gist",
|
|
55
65
|
"description": "",
|
|
56
66
|
"tags": [
|
|
57
67
|
"Gist"
|
|
@@ -77,7 +87,11 @@
|
|
|
77
87
|
"responses": {
|
|
78
88
|
"200": {
|
|
79
89
|
"description": "HAL+JSON representation of Gist Resource. In addition to representing its state in the JSON form it offers affordances in the form of the HTTP Link header and HAL links.",
|
|
80
|
-
"headers": {
|
|
90
|
+
"headers": {
|
|
91
|
+
"Link": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
81
95
|
"examples": {},
|
|
82
96
|
"schema": {
|
|
83
97
|
"$ref": "#/definitions/GistModel"
|
|
@@ -85,6 +99,7 @@
|
|
|
85
99
|
}
|
|
86
100
|
},
|
|
87
101
|
"summary": "Edit a Gist",
|
|
102
|
+
"operationId": "Edit a Gist",
|
|
88
103
|
"description": "To update a Gist send a JSON with updated value for one or more of the Gist resource attributes. All attributes values (states) from the previous version of this Gist are carried over by default if not included in the hash.",
|
|
89
104
|
"tags": [
|
|
90
105
|
"Gist"
|
|
@@ -130,6 +145,7 @@
|
|
|
130
145
|
}
|
|
131
146
|
},
|
|
132
147
|
"summary": "Delete a Gist",
|
|
148
|
+
"operationId": "Delete a Gist",
|
|
133
149
|
"description": "",
|
|
134
150
|
"tags": [
|
|
135
151
|
"Gist"
|
|
@@ -157,7 +173,11 @@
|
|
|
157
173
|
"responses": {
|
|
158
174
|
"200": {
|
|
159
175
|
"description": "HAL+JSON representation of Gist Collection Resource. The Gist resources in collections are embedded. Note the embedded Gists resource are incomplete representations of the Gist in question. Use the respective Gist link to retrieve its full representation.",
|
|
160
|
-
"headers": {
|
|
176
|
+
"headers": {
|
|
177
|
+
"Link": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
161
181
|
"examples": {
|
|
162
182
|
"application/hal+json": {
|
|
163
183
|
"_links": {
|
|
@@ -188,6 +208,7 @@
|
|
|
188
208
|
}
|
|
189
209
|
},
|
|
190
210
|
"summary": "List All Gists",
|
|
211
|
+
"operationId": "List All Gists",
|
|
191
212
|
"description": "",
|
|
192
213
|
"tags": [
|
|
193
214
|
"Gist"
|
|
@@ -209,7 +230,11 @@
|
|
|
209
230
|
"responses": {
|
|
210
231
|
"201": {
|
|
211
232
|
"description": "HAL+JSON representation of Gist Resource. In addition to representing its state in the JSON form it offers affordances in the form of the HTTP Link header and HAL links.",
|
|
212
|
-
"headers": {
|
|
233
|
+
"headers": {
|
|
234
|
+
"Link": {
|
|
235
|
+
"type": "string"
|
|
236
|
+
}
|
|
237
|
+
},
|
|
213
238
|
"examples": {},
|
|
214
239
|
"schema": {
|
|
215
240
|
"$ref": "#/definitions/GistModel"
|
|
@@ -217,6 +242,7 @@
|
|
|
217
242
|
}
|
|
218
243
|
},
|
|
219
244
|
"summary": "Create a Gist",
|
|
245
|
+
"operationId": "Create a Gist",
|
|
220
246
|
"description": "To create a new Gist simply provide a JSON hash of the *description* and *content* attributes for the new Gist.\n\nThis action requires an `access_token` with `gist_write` scope.",
|
|
221
247
|
"tags": [
|
|
222
248
|
"Gist"
|
|
@@ -261,6 +287,7 @@
|
|
|
261
287
|
}
|
|
262
288
|
},
|
|
263
289
|
"summary": "Star a Gist",
|
|
290
|
+
"operationId": "Star a Gist",
|
|
264
291
|
"description": "This action requires an `access_token` with `gist_write` scope.",
|
|
265
292
|
"tags": [
|
|
266
293
|
"Gist"
|
|
@@ -291,6 +318,7 @@
|
|
|
291
318
|
}
|
|
292
319
|
},
|
|
293
320
|
"summary": "Unstar a Gist",
|
|
321
|
+
"operationId": "Unstar a Gist",
|
|
294
322
|
"description": "This action requires an `access_token` with `gist_write` scope.",
|
|
295
323
|
"tags": [
|
|
296
324
|
"Gist"
|
|
@@ -316,7 +344,11 @@
|
|
|
316
344
|
"responses": {
|
|
317
345
|
"200": {
|
|
318
346
|
"description": "HAL+JSON representation of Star Resource.",
|
|
319
|
-
"headers": {
|
|
347
|
+
"headers": {
|
|
348
|
+
"Link": {
|
|
349
|
+
"type": "string"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
320
352
|
"examples": {},
|
|
321
353
|
"schema": {
|
|
322
354
|
"$ref": "#/definitions/StarModel"
|
|
@@ -324,6 +356,7 @@
|
|
|
324
356
|
}
|
|
325
357
|
},
|
|
326
358
|
"summary": "Check if a Gist is Starred",
|
|
359
|
+
"operationId": "Check if a Gist is Starred",
|
|
327
360
|
"description": "",
|
|
328
361
|
"tags": [
|
|
329
362
|
"Gist"
|
|
@@ -351,7 +384,11 @@
|
|
|
351
384
|
"responses": {
|
|
352
385
|
"200": {
|
|
353
386
|
"description": "OK",
|
|
354
|
-
"headers": {
|
|
387
|
+
"headers": {
|
|
388
|
+
"Link": {
|
|
389
|
+
"type": "string"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
355
392
|
"examples": {},
|
|
356
393
|
"schema": {
|
|
357
394
|
"$ref": "#/definitions/AuthorizationModel"
|
|
@@ -359,6 +396,7 @@
|
|
|
359
396
|
}
|
|
360
397
|
},
|
|
361
398
|
"summary": "Retrieve Authorization",
|
|
399
|
+
"operationId": "Retrieve Authorization",
|
|
362
400
|
"description": "",
|
|
363
401
|
"tags": [
|
|
364
402
|
"Access Authorization and Control"
|
|
@@ -379,6 +417,7 @@
|
|
|
379
417
|
}
|
|
380
418
|
},
|
|
381
419
|
"summary": "Create Authorization",
|
|
420
|
+
"operationId": "Create Authorization",
|
|
382
421
|
"description": "",
|
|
383
422
|
"tags": [
|
|
384
423
|
"Access Authorization and Control"
|
|
@@ -420,6 +459,7 @@
|
|
|
420
459
|
}
|
|
421
460
|
},
|
|
422
461
|
"summary": "Remove an Authorization",
|
|
462
|
+
"operationId": "Remove an Authorization",
|
|
423
463
|
"description": "",
|
|
424
464
|
"tags": [
|
|
425
465
|
"Access Authorization and Control"
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"responses": {
|
|
12
12
|
"200": {
|
|
13
13
|
"description": "OK",
|
|
14
|
-
"headers": {
|
|
14
|
+
"headers": {
|
|
15
|
+
"Link": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
15
19
|
"examples": {
|
|
16
20
|
"application/hal+json": {
|
|
17
21
|
"_links": {
|
|
@@ -31,6 +35,7 @@
|
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"summary": "Retrieve the Entry Point",
|
|
38
|
+
"operationId": "Retrieve the Entry Point",
|
|
34
39
|
"description": "",
|
|
35
40
|
"tags": [],
|
|
36
41
|
"parameters": [],
|
|
@@ -44,7 +49,11 @@
|
|
|
44
49
|
"responses": {
|
|
45
50
|
"200": {
|
|
46
51
|
"description": "HAL+JSON representation of Gist Resource. In addition to representing its state in the JSON form it offers affordances in the form of the HTTP Link header and HAL links.",
|
|
47
|
-
"headers": {
|
|
52
|
+
"headers": {
|
|
53
|
+
"Link": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
48
57
|
"examples": {},
|
|
49
58
|
"schema": {
|
|
50
59
|
"$ref": "#/definitions/GistModel"
|
|
@@ -52,6 +61,7 @@
|
|
|
52
61
|
}
|
|
53
62
|
},
|
|
54
63
|
"summary": "Retrieve a Single Gist",
|
|
64
|
+
"operationId": "Retrieve a Single Gist",
|
|
55
65
|
"description": "",
|
|
56
66
|
"tags": [
|
|
57
67
|
"Gist"
|
|
@@ -77,7 +87,11 @@
|
|
|
77
87
|
"responses": {
|
|
78
88
|
"200": {
|
|
79
89
|
"description": "HAL+JSON representation of Gist Resource. In addition to representing its state in the JSON form it offers affordances in the form of the HTTP Link header and HAL links.",
|
|
80
|
-
"headers": {
|
|
90
|
+
"headers": {
|
|
91
|
+
"Link": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
81
95
|
"examples": {},
|
|
82
96
|
"schema": {
|
|
83
97
|
"$ref": "#/definitions/GistModel"
|
|
@@ -85,6 +99,7 @@
|
|
|
85
99
|
}
|
|
86
100
|
},
|
|
87
101
|
"summary": "Edit a Gist",
|
|
102
|
+
"operationId": "Edit a Gist",
|
|
88
103
|
"description": "To update a Gist send a JSON with updated value for one or more of the Gist resource attributes. All attributes values (states) from the previous version of this Gist are carried over by default if not included in the hash.",
|
|
89
104
|
"tags": [
|
|
90
105
|
"Gist"
|
|
@@ -130,6 +145,7 @@
|
|
|
130
145
|
}
|
|
131
146
|
},
|
|
132
147
|
"summary": "Delete a Gist",
|
|
148
|
+
"operationId": "Delete a Gist",
|
|
133
149
|
"description": "",
|
|
134
150
|
"tags": [
|
|
135
151
|
"Gist"
|
|
@@ -157,7 +173,11 @@
|
|
|
157
173
|
"responses": {
|
|
158
174
|
"200": {
|
|
159
175
|
"description": "HAL+JSON representation of Gist Collection Resource. The Gist resources in collections are embedded. Note the embedded Gists resource are incomplete representations of the Gist in question. Use the respective Gist link to retrieve its full representation.",
|
|
160
|
-
"headers": {
|
|
176
|
+
"headers": {
|
|
177
|
+
"Link": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
161
181
|
"examples": {
|
|
162
182
|
"application/hal+json": {
|
|
163
183
|
"_links": {
|
|
@@ -188,6 +208,7 @@
|
|
|
188
208
|
}
|
|
189
209
|
},
|
|
190
210
|
"summary": "List All Gists",
|
|
211
|
+
"operationId": "List All Gists",
|
|
191
212
|
"description": "",
|
|
192
213
|
"tags": [
|
|
193
214
|
"Gist"
|
|
@@ -209,7 +230,11 @@
|
|
|
209
230
|
"responses": {
|
|
210
231
|
"201": {
|
|
211
232
|
"description": "HAL+JSON representation of Gist Resource. In addition to representing its state in the JSON form it offers affordances in the form of the HTTP Link header and HAL links.",
|
|
212
|
-
"headers": {
|
|
233
|
+
"headers": {
|
|
234
|
+
"Link": {
|
|
235
|
+
"type": "string"
|
|
236
|
+
}
|
|
237
|
+
},
|
|
213
238
|
"examples": {},
|
|
214
239
|
"schema": {
|
|
215
240
|
"$ref": "#/definitions/GistModel"
|
|
@@ -217,6 +242,7 @@
|
|
|
217
242
|
}
|
|
218
243
|
},
|
|
219
244
|
"summary": "Create a Gist",
|
|
245
|
+
"operationId": "Create a Gist",
|
|
220
246
|
"description": "To create a new Gist simply provide a JSON hash of the *description* and *content* attributes for the new Gist.\n\nThis action requires an `access_token` with `gist_write` scope.",
|
|
221
247
|
"tags": [
|
|
222
248
|
"Gist"
|
|
@@ -261,6 +287,7 @@
|
|
|
261
287
|
}
|
|
262
288
|
},
|
|
263
289
|
"summary": "Star a Gist",
|
|
290
|
+
"operationId": "Star a Gist",
|
|
264
291
|
"description": "This action requires an `access_token` with `gist_write` scope.",
|
|
265
292
|
"tags": [
|
|
266
293
|
"Gist"
|
|
@@ -291,6 +318,7 @@
|
|
|
291
318
|
}
|
|
292
319
|
},
|
|
293
320
|
"summary": "Unstar a Gist",
|
|
321
|
+
"operationId": "Unstar a Gist",
|
|
294
322
|
"description": "This action requires an `access_token` with `gist_write` scope.",
|
|
295
323
|
"tags": [
|
|
296
324
|
"Gist"
|
|
@@ -316,7 +344,11 @@
|
|
|
316
344
|
"responses": {
|
|
317
345
|
"200": {
|
|
318
346
|
"description": "HAL+JSON representation of Star Resource.",
|
|
319
|
-
"headers": {
|
|
347
|
+
"headers": {
|
|
348
|
+
"Link": {
|
|
349
|
+
"type": "string"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
320
352
|
"examples": {},
|
|
321
353
|
"schema": {
|
|
322
354
|
"$ref": "#/definitions/StarModel"
|
|
@@ -324,6 +356,7 @@
|
|
|
324
356
|
}
|
|
325
357
|
},
|
|
326
358
|
"summary": "Check if a Gist is Starred",
|
|
359
|
+
"operationId": "Check if a Gist is Starred",
|
|
327
360
|
"description": "",
|
|
328
361
|
"tags": [
|
|
329
362
|
"Gist"
|
|
@@ -351,7 +384,11 @@
|
|
|
351
384
|
"responses": {
|
|
352
385
|
"200": {
|
|
353
386
|
"description": "OK",
|
|
354
|
-
"headers": {
|
|
387
|
+
"headers": {
|
|
388
|
+
"Link": {
|
|
389
|
+
"type": "string"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
355
392
|
"examples": {},
|
|
356
393
|
"schema": {
|
|
357
394
|
"$ref": "#/definitions/AuthorizationModel"
|
|
@@ -359,6 +396,7 @@
|
|
|
359
396
|
}
|
|
360
397
|
},
|
|
361
398
|
"summary": "Retrieve Authorization",
|
|
399
|
+
"operationId": "Retrieve Authorization",
|
|
362
400
|
"description": "",
|
|
363
401
|
"tags": [
|
|
364
402
|
"Access Authorization and Control"
|
|
@@ -379,6 +417,7 @@
|
|
|
379
417
|
}
|
|
380
418
|
},
|
|
381
419
|
"summary": "Create Authorization",
|
|
420
|
+
"operationId": "Create Authorization",
|
|
382
421
|
"description": "",
|
|
383
422
|
"tags": [
|
|
384
423
|
"Access Authorization and Control"
|
|
@@ -420,6 +459,7 @@
|
|
|
420
459
|
}
|
|
421
460
|
},
|
|
422
461
|
"summary": "Remove an Authorization",
|
|
462
|
+
"operationId": "Remove an Authorization",
|
|
423
463
|
"description": "",
|
|
424
464
|
"tags": [
|
|
425
465
|
"Access Authorization and Control"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"swagger": "2.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "",
|
|
5
|
+
"version": "",
|
|
6
|
+
"description": ""
|
|
7
|
+
},
|
|
8
|
+
"paths": {
|
|
9
|
+
"/some/resource": {
|
|
10
|
+
"post": {
|
|
11
|
+
"responses": {
|
|
12
|
+
"200": {
|
|
13
|
+
"description": "OK",
|
|
14
|
+
"headers": {},
|
|
15
|
+
"examples": {
|
|
16
|
+
"text/plain": ""
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"summary": "Some resource",
|
|
21
|
+
"operationId": "Some resource",
|
|
22
|
+
"description": "",
|
|
23
|
+
"tags": [],
|
|
24
|
+
"parameters": [
|
|
25
|
+
{
|
|
26
|
+
"name": "body",
|
|
27
|
+
"in": "body",
|
|
28
|
+
"schema": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"prop1": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": [
|
|
36
|
+
"prop1"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"produces": [
|
|
42
|
+
"text/plain"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"definitions": {
|
|
48
|
+
"Some resource": {}
|
|
49
|
+
},
|
|
50
|
+
"securityDefinitions": {},
|
|
51
|
+
"tags": []
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"swagger": "2.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "",
|
|
5
|
+
"version": "",
|
|
6
|
+
"description": ""
|
|
7
|
+
},
|
|
8
|
+
"paths": {
|
|
9
|
+
"/some/resource": {
|
|
10
|
+
"post": {
|
|
11
|
+
"responses": {
|
|
12
|
+
"200": {
|
|
13
|
+
"description": "OK",
|
|
14
|
+
"headers": {},
|
|
15
|
+
"examples": {
|
|
16
|
+
"text/plain": ""
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"summary": "Some resource",
|
|
21
|
+
"operationId": "Some resource",
|
|
22
|
+
"description": "",
|
|
23
|
+
"tags": [],
|
|
24
|
+
"parameters": [
|
|
25
|
+
{
|
|
26
|
+
"name": "body",
|
|
27
|
+
"in": "body",
|
|
28
|
+
"schema": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"prop1": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": [
|
|
36
|
+
"prop1"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"produces": [
|
|
42
|
+
"text/plain"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"definitions": {
|
|
48
|
+
"Some resource": {}
|
|
49
|
+
},
|
|
50
|
+
"securityDefinitions": {},
|
|
51
|
+
"tags": []
|
|
52
|
+
}
|
|
File without changes
|
package/test/test.js
CHANGED
|
@@ -4,6 +4,14 @@ var assert = require("assert"),
|
|
|
4
4
|
apib2swagger = require("../index.js"),
|
|
5
5
|
tv4 = require('tv4');
|
|
6
6
|
|
|
7
|
+
const swaggerSchema = JSON.parse(fs.readFileSync('test/swagger_20_schema.json'));
|
|
8
|
+
const openAPI3Schema = JSON.parse(fs.readFileSync('test/openAPI_30_schema.json'))
|
|
9
|
+
const meta_schema = JSON.parse(fs.readFileSync('test/meta_schema.json'));
|
|
10
|
+
|
|
11
|
+
tv4.addSchema('http://json-schema.org/draft-04/schema', meta_schema);
|
|
12
|
+
tv4.addSchema('https://spec.openapis.org/oas/3.0/schema/2021-09-28', openAPI3Schema);
|
|
13
|
+
tv4.addSchema('http://swagger.io/v2/schema.json', swaggerSchema);
|
|
14
|
+
|
|
7
15
|
var remote = 'https://raw.githubusercontent.com/apiaryio/api-blueprint/format-1A9/examples/',
|
|
8
16
|
localInput = 'test/input/',
|
|
9
17
|
localOutput = 'test/output/',
|
|
@@ -37,8 +45,15 @@ var remote = 'https://raw.githubusercontent.com/apiaryio/api-blueprint/format-1A
|
|
|
37
45
|
'Issue-#35.md',
|
|
38
46
|
'Issue-#36.md',
|
|
39
47
|
'Issue-#38.md',
|
|
48
|
+
'Issue-#49.md',
|
|
40
49
|
'apiblueprint_uber.md',
|
|
41
|
-
'apiblueprint_valid_simple.md'
|
|
50
|
+
'apiblueprint_valid_simple.md',
|
|
51
|
+
'schema_without_body.md',
|
|
52
|
+
'OpenAPI3_responses.md',
|
|
53
|
+
'OpenAPI3_requests.md',
|
|
54
|
+
'OpenAPI3_headers.md',
|
|
55
|
+
'OpenAPI3_includes.md',
|
|
56
|
+
'OpenAPI3_attributes.md'
|
|
42
57
|
];
|
|
43
58
|
|
|
44
59
|
var fetch = function (file) {
|
|
@@ -46,7 +61,7 @@ var fetch = function (file) {
|
|
|
46
61
|
return Promise.resolve();
|
|
47
62
|
}
|
|
48
63
|
console.log('Downloading ' + remote + file + ')');
|
|
49
|
-
return new Promise(function(resolve, reject) {
|
|
64
|
+
return new Promise(function (resolve, reject) {
|
|
50
65
|
https.get(remote + file, function (res) {
|
|
51
66
|
if (res.statusCode !== 200) {
|
|
52
67
|
}
|
|
@@ -78,6 +93,7 @@ const checkResultByFile = (result, file, originalExtension, newExtension) => {
|
|
|
78
93
|
var f = fs.readFileSync(localOutput + file.replace(originalExtension, newExtension));
|
|
79
94
|
var expected_answer = JSON.parse(f);
|
|
80
95
|
assert.deepEqual(result.swagger, expected_answer);
|
|
96
|
+
const schema = file.includes('OpenAPI3') ? openAPI3Schema : swaggerSchema
|
|
81
97
|
var validation_result = tv4.validateResult(result.swagger, schema);
|
|
82
98
|
if (validation_result.error) {
|
|
83
99
|
console.log(validation_result);
|
|
@@ -94,16 +110,16 @@ describe("apib2swagger", function () {
|
|
|
94
110
|
return Promise.all(files.map(fetch));
|
|
95
111
|
});
|
|
96
112
|
|
|
97
|
-
schema = JSON.parse(fs.readFileSync('test/swagger_20_schema.json'));
|
|
98
|
-
tv4.addSchema('http://swagger.io/v2/schema.json', schema);
|
|
99
|
-
meta_schema = JSON.parse(fs.readFileSync('test/meta_schema.json'));
|
|
100
|
-
tv4.addSchema('http://json-schema.org/draft-04/schema', meta_schema);
|
|
101
|
-
|
|
102
113
|
files.concat(includedFiles).forEach(function (file) {
|
|
114
|
+
const options = {}
|
|
115
|
+
if (file.includes('OpenAPI3')){
|
|
116
|
+
options.openApi3 = true
|
|
117
|
+
}
|
|
118
|
+
|
|
103
119
|
it(file, function (done) {
|
|
104
120
|
this.timeout(10000); // 10s
|
|
105
121
|
var apib = fs.readFileSync(localInput + file, "utf-8").replace(/\r/g, '');
|
|
106
|
-
apib2swagger.convert(apib, function (error, result) {
|
|
122
|
+
apib2swagger.convert(apib, options, function (error, result) {
|
|
107
123
|
if (error) {
|
|
108
124
|
return done(error);
|
|
109
125
|
}
|
|
@@ -116,7 +132,7 @@ describe("apib2swagger", function () {
|
|
|
116
132
|
it(file + ' (--prefer-reference)', function (done) {
|
|
117
133
|
this.timeout(10000); // 10s
|
|
118
134
|
var apib = fs.readFileSync(localInput + file, "utf-8").replace(/\r/g, '');
|
|
119
|
-
apib2swagger.convert(apib, { preferReference: true }, function (error, result) {
|
|
135
|
+
apib2swagger.convert(apib, { ...options, preferReference: true }, function (error, result) {
|
|
120
136
|
if (error) {
|
|
121
137
|
return done(error);
|
|
122
138
|
}
|
|
@@ -128,9 +144,9 @@ describe("apib2swagger", function () {
|
|
|
128
144
|
});
|
|
129
145
|
|
|
130
146
|
var versionTests = [
|
|
131
|
-
{input: 'VERSION: 1.0.0', output: '1.0.0'},
|
|
132
|
-
{input: 'Version: 2.0', output: '2.0'},
|
|
133
|
-
{input: 'version: 3', output: '3'},
|
|
147
|
+
{ input: 'VERSION: 1.0.0', output: '1.0.0' },
|
|
148
|
+
{ input: 'Version: 2.0', output: '2.0' },
|
|
149
|
+
{ input: 'version: 3', output: '3' },
|
|
134
150
|
];
|
|
135
151
|
versionTests.forEach(function (test) {
|
|
136
152
|
it(test.input, function (done) {
|
|
@@ -139,18 +155,18 @@ describe("apib2swagger", function () {
|
|
|
139
155
|
return done(error);
|
|
140
156
|
}
|
|
141
157
|
assert.equal(result.swagger.info.version, test.output);
|
|
142
|
-
var validation_result = tv4.validateResult(result.swagger,
|
|
158
|
+
var validation_result = tv4.validateResult(result.swagger, swaggerSchema);
|
|
143
159
|
if (validation_result.error) {
|
|
144
160
|
console.log(validation_result);
|
|
145
161
|
}
|
|
146
162
|
assert(validation_result.valid);
|
|
147
163
|
assert(validation_result.missing.length === 0)
|
|
148
164
|
done();
|
|
149
|
-
});
|
|
165
|
+
});
|
|
150
166
|
});
|
|
151
167
|
});
|
|
152
168
|
|
|
153
|
-
it('Issue-#38.md (--bearer-apikey', function(done) {
|
|
169
|
+
it('Issue-#38.md (--bearer-apikey', function (done) {
|
|
154
170
|
const file = 'Issue-#38.md';
|
|
155
171
|
this.timeout(10000); // 10s
|
|
156
172
|
var apib = fs.readFileSync(localInput + file, "utf-8").replace(/\r/g, '');
|