apib2swagger 1.12.0 → 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.
Files changed (118) hide show
  1. package/.github/workflows/codeql-analysis.yml +71 -0
  2. package/.github/workflows/docker-publish.yml +1 -1
  3. package/.github/workflows/nodejs.yml +1 -1
  4. package/.travis.yml +2 -1
  5. package/Dockerfile +1 -1
  6. package/LICENSE +0 -0
  7. package/README.md +29 -3
  8. package/bin/apib2swagger.js +43 -17
  9. package/index.js +81 -366
  10. package/package.json +5 -3
  11. package/src/escape_json_pointer.js +0 -0
  12. package/src/mson_to_json_schema.js +12 -10
  13. package/src/parameters.js +111 -0
  14. package/src/requests.js +344 -0
  15. package/src/responses.js +181 -0
  16. package/src/util.js +127 -0
  17. package/test/input/Attributes.md +0 -0
  18. package/test/input/Issue-#15.md +0 -0
  19. package/test/input/Issue-#22.md +0 -0
  20. package/test/input/Issue-#23.md +0 -0
  21. package/test/input/Issue-#26.md +0 -0
  22. package/test/input/Issue-#29.md +0 -0
  23. package/test/input/Issue-#33.md +0 -0
  24. package/test/input/Issue-#35.md +0 -0
  25. package/test/input/Issue-#36.md +0 -0
  26. package/test/input/Issue-#38.md +0 -0
  27. package/test/input/Issue-#49.md +0 -0
  28. package/test/input/OpenAPI3_attributes.md +36 -0
  29. package/test/input/OpenAPI3_headers.md +74 -0
  30. package/test/input/OpenAPI3_includes.md +22 -0
  31. package/test/input/OpenAPI3_requests.md +162 -0
  32. package/test/input/OpenAPI3_responses.md +177 -0
  33. package/test/input/Schema.md +0 -0
  34. package/test/input/apiblueprint_uber.md +0 -0
  35. package/test/input/apiblueprint_valid_simple.md +0 -0
  36. package/test/input/includes/resource-request-body-2.json +3 -0
  37. package/test/input/includes/resource-request-body.json +3 -0
  38. package/test/input/includes/resource-request-schema.json +9 -0
  39. package/test/input/includes/resource-response-body-2.json +3 -0
  40. package/test/input/includes/resource-response-body.json +3 -0
  41. package/test/input/includes/resource-response-schema.json +9 -0
  42. package/test/input/schema_without_body.md +17 -0
  43. package/test/meta_schema.json +0 -0
  44. package/test/openAPI_30_schema.json +1662 -0
  45. package/test/output/01. Simplest API.json +0 -0
  46. package/test/output/01. Simplest API.ref.json +0 -0
  47. package/test/output/02. Resource and Actions.json +0 -0
  48. package/test/output/02. Resource and Actions.ref.json +0 -0
  49. package/test/output/03. Named Resource and Actions.json +0 -0
  50. package/test/output/03. Named Resource and Actions.ref.json +0 -0
  51. package/test/output/04. Grouping Resources.json +0 -0
  52. package/test/output/04. Grouping Resources.ref.json +0 -0
  53. package/test/output/05. Responses.json +0 -0
  54. package/test/output/05. Responses.ref.json +0 -0
  55. package/test/output/06. Requests.json +0 -0
  56. package/test/output/06. Requests.ref.json +0 -0
  57. package/test/output/07. Parameters.json +0 -0
  58. package/test/output/07. Parameters.ref.json +0 -0
  59. package/test/output/08. Attributes.json +0 -0
  60. package/test/output/08. Attributes.ref.json +0 -0
  61. package/test/output/09. Advanced Attributes.json +0 -0
  62. package/test/output/09. Advanced Attributes.ref.json +0 -0
  63. package/test/output/10. Data Structures.json +0 -0
  64. package/test/output/10. Data Structures.ref.json +0 -0
  65. package/test/output/11. Resource Model.json +0 -0
  66. package/test/output/11. Resource Model.ref.json +0 -0
  67. package/test/output/12. Advanced Action.json +0 -0
  68. package/test/output/12. Advanced Action.ref.json +0 -0
  69. package/test/output/13. Named Endpoints.json +0 -0
  70. package/test/output/13. Named Endpoints.ref.json +0 -0
  71. package/test/output/Attributes.json +0 -0
  72. package/test/output/Attributes.ref.json +0 -0
  73. package/test/output/Gist Fox API + Auth.json +0 -0
  74. package/test/output/Gist Fox API + Auth.ref.json +0 -0
  75. package/test/output/Issue-#15.json +0 -0
  76. package/test/output/Issue-#15.ref.json +0 -0
  77. package/test/output/Issue-#22.json +0 -0
  78. package/test/output/Issue-#22.ref.json +0 -0
  79. package/test/output/Issue-#23.json +0 -0
  80. package/test/output/Issue-#23.ref.json +0 -0
  81. package/test/output/Issue-#26.json +0 -0
  82. package/test/output/Issue-#26.ref.json +0 -0
  83. package/test/output/Issue-#29.json +0 -0
  84. package/test/output/Issue-#29.ref.json +0 -0
  85. package/test/output/Issue-#33.json +0 -0
  86. package/test/output/Issue-#33.ref.json +0 -0
  87. package/test/output/Issue-#35.json +0 -0
  88. package/test/output/Issue-#35.ref.json +0 -0
  89. package/test/output/Issue-#36.json +0 -0
  90. package/test/output/Issue-#36.ref.json +0 -0
  91. package/test/output/Issue-#38.bearer.json +0 -0
  92. package/test/output/Issue-#38.json +0 -0
  93. package/test/output/Issue-#38.ref.json +0 -0
  94. package/test/output/Issue-#49.json +0 -0
  95. package/test/output/Issue-#49.ref.json +0 -0
  96. package/test/output/OpenAPI3_attributes.json +199 -0
  97. package/test/output/OpenAPI3_attributes.ref.json +173 -0
  98. package/test/output/OpenAPI3_headers.json +169 -0
  99. package/test/output/OpenAPI3_headers.ref.json +169 -0
  100. package/test/output/OpenAPI3_includes.json +66 -0
  101. package/test/output/OpenAPI3_includes.ref.json +66 -0
  102. package/test/output/OpenAPI3_requests.json +326 -0
  103. package/test/output/OpenAPI3_requests.ref.json +321 -0
  104. package/test/output/OpenAPI3_responses.json +255 -0
  105. package/test/output/OpenAPI3_responses.ref.json +245 -0
  106. package/test/output/Schema.json +0 -0
  107. package/test/output/Schema.ref.json +0 -0
  108. package/test/output/apiblueprint_uber.json +0 -0
  109. package/test/output/apiblueprint_uber.ref.json +0 -0
  110. package/test/output/apiblueprint_valid_simple.json +0 -0
  111. package/test/output/apiblueprint_valid_simple.ref.json +0 -0
  112. package/test/output/schema_without_body.json +52 -0
  113. package/test/output/schema_without_body.ref.json +52 -0
  114. package/test/swagger_20_schema.json +0 -0
  115. package/test/test.js +24 -9
  116. package/test/util.test.js +151 -0
  117. package/.npmignore +0 -35
  118. package/package-lock.json +0 -2021
@@ -0,0 +1,326 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "",
5
+ "version": "1.0.0",
6
+ "description": ""
7
+ },
8
+ "servers": [
9
+ {
10
+ "url": "https://www.testhost.com"
11
+ }
12
+ ],
13
+ "paths": {
14
+ "/some/resource/{pathParam}": {
15
+ "get": {
16
+ "responses": {
17
+ "200": {
18
+ "description": "OK",
19
+ "headers": {},
20
+ "content": {}
21
+ }
22
+ },
23
+ "summary": "Some resource",
24
+ "operationId": "Some resource",
25
+ "description": "",
26
+ "tags": [],
27
+ "parameters": [
28
+ {
29
+ "name": "pathParam",
30
+ "in": "path",
31
+ "description": "",
32
+ "required": true,
33
+ "example": "exampleValue",
34
+ "schema": {
35
+ "type": "string",
36
+ "default": "defaultValue"
37
+ }
38
+ },
39
+ {
40
+ "name": "queryParam",
41
+ "in": "query",
42
+ "description": "",
43
+ "required": true,
44
+ "example": "value1",
45
+ "schema": {
46
+ "type": "string",
47
+ "enum": [
48
+ "value1",
49
+ "value2"
50
+ ]
51
+ }
52
+ },
53
+ {
54
+ "name": "additionalQueryParam",
55
+ "in": "query",
56
+ "description": "",
57
+ "required": true,
58
+ "schema": {
59
+ "type": "string"
60
+ }
61
+ }
62
+ ],
63
+ "requestBody": {
64
+ "content": {
65
+ "application/json": {
66
+ "schema": {
67
+ "oneOf": [
68
+ {
69
+ "type": "object",
70
+ "properties": {
71
+ "message1": {
72
+ "type": "string",
73
+ "description": "This is the message description "
74
+ }
75
+ }
76
+ },
77
+ {
78
+ "type": "object",
79
+ "properties": {
80
+ "message2": {
81
+ "type": "string",
82
+ "description": "This is the message description "
83
+ }
84
+ }
85
+ },
86
+ {
87
+ "type": "object",
88
+ "properties": {
89
+ "message3": {
90
+ "type": "string",
91
+ "description": "This is the message description "
92
+ }
93
+ }
94
+ }
95
+ ]
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ },
102
+ "/another/resource/": {
103
+ "get": {
104
+ "responses": {
105
+ "200": {
106
+ "description": "OK",
107
+ "headers": {},
108
+ "content": {}
109
+ }
110
+ },
111
+ "summary": "Another resource",
112
+ "operationId": "Another resource",
113
+ "description": "",
114
+ "tags": [],
115
+ "parameters": [],
116
+ "requestBody": {
117
+ "content": {
118
+ "application/json": {
119
+ "examples": {
120
+ "example1": {
121
+ "value": {
122
+ "message1": "Hello world"
123
+ }
124
+ },
125
+ "example2": {
126
+ "value": {
127
+ "message2": "Hello world"
128
+ }
129
+ }
130
+ },
131
+ "schema": {
132
+ "oneOf": [
133
+ {
134
+ "type": "object",
135
+ "properties": {
136
+ "message1": {
137
+ "type": "string",
138
+ "description": "This is the message description "
139
+ }
140
+ }
141
+ },
142
+ {
143
+ "type": "object",
144
+ "properties": {
145
+ "message2": {
146
+ "type": "string",
147
+ "description": "This is the message description "
148
+ }
149
+ }
150
+ }
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ },
158
+ "/withAttributes": {
159
+ "get": {
160
+ "responses": {
161
+ "200": {
162
+ "description": "OK",
163
+ "headers": {},
164
+ "content": {}
165
+ }
166
+ },
167
+ "summary": "Some resource",
168
+ "operationId": "Some resource",
169
+ "description": "",
170
+ "tags": [],
171
+ "parameters": [],
172
+ "requestBody": {
173
+ "content": {
174
+ "application/json": {
175
+ "example": {
176
+ "message": ""
177
+ },
178
+ "schema": {
179
+ "oneOf": [
180
+ {
181
+ "type": "object",
182
+ "properties": {
183
+ "someType": {
184
+ "type": "string",
185
+ "description": "This is the message description "
186
+ }
187
+ }
188
+ },
189
+ {
190
+ "type": "object",
191
+ "properties": {
192
+ "message": {
193
+ "type": "string"
194
+ }
195
+ }
196
+ }
197
+ ]
198
+ }
199
+ }
200
+ }
201
+ }
202
+ }
203
+ },
204
+ "/onlyAttributes": {
205
+ "get": {
206
+ "responses": {
207
+ "200": {
208
+ "description": "OK",
209
+ "headers": {},
210
+ "content": {}
211
+ }
212
+ },
213
+ "summary": "Some resource",
214
+ "operationId": "Some resource",
215
+ "description": "",
216
+ "tags": [],
217
+ "parameters": [],
218
+ "requestBody": {
219
+ "content": {
220
+ "application/json": {
221
+ "schema": {
222
+ "$ref": "#/components/schemas/Message"
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+ },
229
+ "/onlyExamples": {
230
+ "get": {
231
+ "responses": {
232
+ "200": {
233
+ "description": "OK",
234
+ "headers": {},
235
+ "content": {}
236
+ }
237
+ },
238
+ "summary": "Some resource",
239
+ "operationId": "Some resource",
240
+ "description": "",
241
+ "tags": [],
242
+ "parameters": [],
243
+ "requestBody": {
244
+ "content": {
245
+ "application/json": {
246
+ "examples": {
247
+ "example1": {
248
+ "value": {
249
+ "message": "test1"
250
+ }
251
+ },
252
+ "example2": {
253
+ "value": {
254
+ "message": "test2"
255
+ }
256
+ },
257
+ "example3": {
258
+ "value": {
259
+ "message": "test3"
260
+ }
261
+ }
262
+ },
263
+ "schema": {
264
+ "type": "object",
265
+ "properties": {
266
+ "message": {
267
+ "type": "string"
268
+ }
269
+ }
270
+ }
271
+ },
272
+ "text/plain": {
273
+ "example": "test\n"
274
+ }
275
+ }
276
+ }
277
+ }
278
+ },
279
+ "/bodyOnly": {
280
+ "get": {
281
+ "responses": {
282
+ "200": {
283
+ "description": "OK",
284
+ "headers": {},
285
+ "content": {}
286
+ }
287
+ },
288
+ "summary": "Some resource",
289
+ "operationId": "Some resource",
290
+ "description": "",
291
+ "tags": [],
292
+ "parameters": [],
293
+ "requestBody": {
294
+ "content": {
295
+ "application/json": {
296
+ "example": {
297
+ "message": "test2"
298
+ },
299
+ "schema": {
300
+ "type": "object",
301
+ "properties": {
302
+ "message": {
303
+ "type": "string"
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+ }
310
+ }
311
+ }
312
+ },
313
+ "components": {
314
+ "schemas": {
315
+ "Message": {
316
+ "type": "object",
317
+ "properties": {
318
+ "message": {
319
+ "type": "string"
320
+ }
321
+ }
322
+ }
323
+ }
324
+ },
325
+ "tags": []
326
+ }
@@ -0,0 +1,321 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "",
5
+ "version": "1.0.0",
6
+ "description": ""
7
+ },
8
+ "servers": [
9
+ {
10
+ "url": "https://www.testhost.com"
11
+ }
12
+ ],
13
+ "paths": {
14
+ "/some/resource/{pathParam}": {
15
+ "get": {
16
+ "responses": {
17
+ "200": {
18
+ "description": "OK",
19
+ "headers": {},
20
+ "content": {}
21
+ }
22
+ },
23
+ "summary": "Some resource",
24
+ "operationId": "Some resource",
25
+ "description": "",
26
+ "tags": [],
27
+ "parameters": [
28
+ {
29
+ "name": "pathParam",
30
+ "in": "path",
31
+ "description": "",
32
+ "required": true,
33
+ "example": "exampleValue",
34
+ "schema": {
35
+ "type": "string",
36
+ "default": "defaultValue"
37
+ }
38
+ },
39
+ {
40
+ "name": "queryParam",
41
+ "in": "query",
42
+ "description": "",
43
+ "required": true,
44
+ "example": "value1",
45
+ "schema": {
46
+ "type": "string",
47
+ "enum": [
48
+ "value1",
49
+ "value2"
50
+ ]
51
+ }
52
+ },
53
+ {
54
+ "name": "additionalQueryParam",
55
+ "in": "query",
56
+ "description": "",
57
+ "required": true,
58
+ "schema": {
59
+ "type": "string"
60
+ }
61
+ }
62
+ ],
63
+ "requestBody": {
64
+ "content": {
65
+ "application/json": {
66
+ "schema": {
67
+ "oneOf": [
68
+ {
69
+ "type": "object",
70
+ "properties": {
71
+ "message1": {
72
+ "type": "string",
73
+ "description": "This is the message description "
74
+ }
75
+ }
76
+ },
77
+ {
78
+ "type": "object",
79
+ "properties": {
80
+ "message2": {
81
+ "type": "string",
82
+ "description": "This is the message description "
83
+ }
84
+ }
85
+ },
86
+ {
87
+ "type": "object",
88
+ "properties": {
89
+ "message3": {
90
+ "type": "string",
91
+ "description": "This is the message description "
92
+ }
93
+ }
94
+ }
95
+ ]
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ },
102
+ "/another/resource/": {
103
+ "get": {
104
+ "responses": {
105
+ "200": {
106
+ "description": "OK",
107
+ "headers": {},
108
+ "content": {}
109
+ }
110
+ },
111
+ "summary": "Another resource",
112
+ "operationId": "Another resource",
113
+ "description": "",
114
+ "tags": [],
115
+ "parameters": [],
116
+ "requestBody": {
117
+ "content": {
118
+ "application/json": {
119
+ "examples": {
120
+ "example1": {
121
+ "value": {
122
+ "message1": "Hello world"
123
+ }
124
+ },
125
+ "example2": {
126
+ "value": {
127
+ "message2": "Hello world"
128
+ }
129
+ }
130
+ },
131
+ "schema": {
132
+ "oneOf": [
133
+ {
134
+ "type": "object",
135
+ "properties": {
136
+ "message1": {
137
+ "type": "string",
138
+ "description": "This is the message description "
139
+ }
140
+ }
141
+ },
142
+ {
143
+ "type": "object",
144
+ "properties": {
145
+ "message2": {
146
+ "type": "string",
147
+ "description": "This is the message description "
148
+ }
149
+ }
150
+ }
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ },
158
+ "/withAttributes": {
159
+ "get": {
160
+ "responses": {
161
+ "200": {
162
+ "description": "OK",
163
+ "headers": {},
164
+ "content": {}
165
+ }
166
+ },
167
+ "summary": "Some resource",
168
+ "operationId": "Some resource",
169
+ "description": "",
170
+ "tags": [],
171
+ "parameters": [],
172
+ "requestBody": {
173
+ "content": {
174
+ "application/json": {
175
+ "example": {
176
+ "message": ""
177
+ },
178
+ "schema": {
179
+ "oneOf": [
180
+ {
181
+ "type": "object",
182
+ "properties": {
183
+ "someType": {
184
+ "type": "string",
185
+ "description": "This is the message description "
186
+ }
187
+ }
188
+ },
189
+ {
190
+ "$ref": "#/components/schemas/Message"
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ },
199
+ "/onlyAttributes": {
200
+ "get": {
201
+ "responses": {
202
+ "200": {
203
+ "description": "OK",
204
+ "headers": {},
205
+ "content": {}
206
+ }
207
+ },
208
+ "summary": "Some resource",
209
+ "operationId": "Some resource",
210
+ "description": "",
211
+ "tags": [],
212
+ "parameters": [],
213
+ "requestBody": {
214
+ "content": {
215
+ "application/json": {
216
+ "schema": {
217
+ "$ref": "#/components/schemas/Message"
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ },
224
+ "/onlyExamples": {
225
+ "get": {
226
+ "responses": {
227
+ "200": {
228
+ "description": "OK",
229
+ "headers": {},
230
+ "content": {}
231
+ }
232
+ },
233
+ "summary": "Some resource",
234
+ "operationId": "Some resource",
235
+ "description": "",
236
+ "tags": [],
237
+ "parameters": [],
238
+ "requestBody": {
239
+ "content": {
240
+ "application/json": {
241
+ "examples": {
242
+ "example1": {
243
+ "value": {
244
+ "message": "test1"
245
+ }
246
+ },
247
+ "example2": {
248
+ "value": {
249
+ "message": "test2"
250
+ }
251
+ },
252
+ "example3": {
253
+ "value": {
254
+ "message": "test3"
255
+ }
256
+ }
257
+ },
258
+ "schema": {
259
+ "type": "object",
260
+ "properties": {
261
+ "message": {
262
+ "type": "string"
263
+ }
264
+ }
265
+ }
266
+ },
267
+ "text/plain": {
268
+ "example": "test\n"
269
+ }
270
+ }
271
+ }
272
+ }
273
+ },
274
+ "/bodyOnly": {
275
+ "get": {
276
+ "responses": {
277
+ "200": {
278
+ "description": "OK",
279
+ "headers": {},
280
+ "content": {}
281
+ }
282
+ },
283
+ "summary": "Some resource",
284
+ "operationId": "Some resource",
285
+ "description": "",
286
+ "tags": [],
287
+ "parameters": [],
288
+ "requestBody": {
289
+ "content": {
290
+ "application/json": {
291
+ "example": {
292
+ "message": "test2"
293
+ },
294
+ "schema": {
295
+ "type": "object",
296
+ "properties": {
297
+ "message": {
298
+ "type": "string"
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ }
305
+ }
306
+ }
307
+ },
308
+ "components": {
309
+ "schemas": {
310
+ "Message": {
311
+ "type": "object",
312
+ "properties": {
313
+ "message": {
314
+ "type": "string"
315
+ }
316
+ }
317
+ }
318
+ }
319
+ },
320
+ "tags": []
321
+ }