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,255 @@
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": {
15
+ "get": {
16
+ "responses": {
17
+ "200": {
18
+ "description": "Array schema",
19
+ "headers": {
20
+ "X-My-Message-Header": {
21
+ "schema": {
22
+ "type": "string"
23
+ }
24
+ }
25
+ },
26
+ "content": {
27
+ "application/json": {
28
+ "schema": {
29
+ "oneOf": [
30
+ {
31
+ "type": "object",
32
+ "properties": {
33
+ "message": {
34
+ "type": "string",
35
+ "description": "This is the message description "
36
+ }
37
+ }
38
+ },
39
+ {
40
+ "type": "object",
41
+ "properties": {
42
+ "other": {
43
+ "type": "string",
44
+ "description": "This is the message description "
45
+ }
46
+ }
47
+ },
48
+ {
49
+ "type": "array",
50
+ "items": {
51
+ "type": "object",
52
+ "properties": {
53
+ "message": {
54
+ "type": "string",
55
+ "description": "This is the message description "
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ]
61
+ },
62
+ "examples": {
63
+ "example1": {
64
+ "value": {
65
+ "message": "Hello World!"
66
+ }
67
+ },
68
+ "example2": {
69
+ "value": {
70
+ "other": "Hello World!"
71
+ }
72
+ },
73
+ "example3": {
74
+ "value": {
75
+ "other": "Hello World!"
76
+ }
77
+ },
78
+ "example4": {
79
+ "value": [
80
+ {
81
+ "message": "Hello World!"
82
+ }
83
+ ]
84
+ }
85
+ }
86
+ }
87
+ }
88
+ },
89
+ "400": {
90
+ "description": "Bad Request",
91
+ "headers": {},
92
+ "content": {
93
+ "application/json": {
94
+ "example": {
95
+ "message": "Invalid data"
96
+ }
97
+ }
98
+ }
99
+ }
100
+ },
101
+ "summary": "Some resource",
102
+ "operationId": "Some resource",
103
+ "description": "",
104
+ "tags": [],
105
+ "parameters": []
106
+ },
107
+ "post": {
108
+ "responses": {
109
+ "200": {
110
+ "description": "OK",
111
+ "headers": {
112
+ "X-My-Message-Header": {
113
+ "schema": {
114
+ "type": "string"
115
+ }
116
+ }
117
+ },
118
+ "content": {
119
+ "application/json": {
120
+ "schema": {
121
+ "type": "object",
122
+ "properties": {
123
+ "message": {
124
+ "type": "string",
125
+ "description": "This is the message description "
126
+ }
127
+ }
128
+ },
129
+ "examples": {
130
+ "example1": {
131
+ "value": {
132
+ "message": "Hello World!"
133
+ }
134
+ },
135
+ "example2": {
136
+ "value": {
137
+ "message": "Hello World!"
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ },
145
+ "summary": "Some resource",
146
+ "operationId": "Some resource",
147
+ "description": "",
148
+ "tags": [],
149
+ "parameters": []
150
+ }
151
+ },
152
+ "/test/attributes": {
153
+ "get": {
154
+ "responses": {
155
+ "200": {
156
+ "description": "OK",
157
+ "headers": {},
158
+ "content": {
159
+ "application/json": {
160
+ "schema": {
161
+ "oneOf": [
162
+ {
163
+ "type": "object",
164
+ "properties": {
165
+ "message": {
166
+ "type": "string"
167
+ }
168
+ }
169
+ },
170
+ {
171
+ "type": "object",
172
+ "properties": {
173
+ "otherMessage": {
174
+ "type": "string"
175
+ }
176
+ }
177
+ }
178
+ ]
179
+ },
180
+ "examples": {
181
+ "example1": {
182
+ "value": {
183
+ "message": "Hello World!"
184
+ }
185
+ },
186
+ "example2": {
187
+ "value": {
188
+ "message": "Hello World2"
189
+ }
190
+ },
191
+ "example3": {
192
+ "value": {
193
+ "otherMessage": "Hello World!"
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ },
201
+ "summary": "Some resource",
202
+ "operationId": "Some resource",
203
+ "description": "",
204
+ "tags": [],
205
+ "parameters": []
206
+ }
207
+ },
208
+ "/message": {
209
+ "get": {
210
+ "responses": {
211
+ "200": {
212
+ "description": "Unparsable schema should fall back to Attributes",
213
+ "headers": {},
214
+ "content": {
215
+ "application/json": {
216
+ "schema": {
217
+ "$ref": "#/components/schemas/Message"
218
+ },
219
+ "example": {
220
+ "message": ""
221
+ }
222
+ }
223
+ }
224
+ }
225
+ },
226
+ "summary": "Message",
227
+ "operationId": "Message",
228
+ "description": "",
229
+ "tags": [],
230
+ "parameters": []
231
+ }
232
+ }
233
+ },
234
+ "components": {
235
+ "schemas":{
236
+ "Message": {
237
+ "type": "object",
238
+ "properties": {
239
+ "message": {
240
+ "type": "string"
241
+ }
242
+ }
243
+ },
244
+ "OtherMessage": {
245
+ "type": "object",
246
+ "properties": {
247
+ "otherMessage": {
248
+ "type": "string"
249
+ }
250
+ }
251
+ }
252
+ }
253
+ },
254
+ "tags": []
255
+ }
@@ -0,0 +1,245 @@
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": {
15
+ "get": {
16
+ "responses": {
17
+ "200": {
18
+ "description": "Array schema",
19
+ "headers": {
20
+ "X-My-Message-Header": {
21
+ "schema": {
22
+ "type": "string"
23
+ }
24
+ }
25
+ },
26
+ "content": {
27
+ "application/json": {
28
+ "schema": {
29
+ "oneOf": [
30
+ {
31
+ "type": "object",
32
+ "properties": {
33
+ "message": {
34
+ "type": "string",
35
+ "description": "This is the message description "
36
+ }
37
+ }
38
+ },
39
+ {
40
+ "type": "object",
41
+ "properties": {
42
+ "other": {
43
+ "type": "string",
44
+ "description": "This is the message description "
45
+ }
46
+ }
47
+ },
48
+ {
49
+ "type": "array",
50
+ "items": {
51
+ "type": "object",
52
+ "properties": {
53
+ "message": {
54
+ "type": "string",
55
+ "description": "This is the message description "
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ]
61
+ },
62
+ "examples": {
63
+ "example1": {
64
+ "value": {
65
+ "message": "Hello World!"
66
+ }
67
+ },
68
+ "example2": {
69
+ "value": {
70
+ "other": "Hello World!"
71
+ }
72
+ },
73
+ "example3": {
74
+ "value": {
75
+ "other": "Hello World!"
76
+ }
77
+ },
78
+ "example4": {
79
+ "value": [
80
+ {
81
+ "message": "Hello World!"
82
+ }
83
+ ]
84
+ }
85
+ }
86
+ }
87
+ }
88
+ },
89
+ "400": {
90
+ "description": "Bad Request",
91
+ "headers": {},
92
+ "content": {
93
+ "application/json": {
94
+ "example": {
95
+ "message": "Invalid data"
96
+ }
97
+ }
98
+ }
99
+ }
100
+ },
101
+ "summary": "Some resource",
102
+ "operationId": "Some resource",
103
+ "description": "",
104
+ "tags": [],
105
+ "parameters": []
106
+ },
107
+ "post": {
108
+ "responses": {
109
+ "200": {
110
+ "description": "OK",
111
+ "headers": {
112
+ "X-My-Message-Header": {
113
+ "schema": {
114
+ "type": "string"
115
+ }
116
+ }
117
+ },
118
+ "content": {
119
+ "application/json": {
120
+ "schema": {
121
+ "type": "object",
122
+ "properties": {
123
+ "message": {
124
+ "type": "string",
125
+ "description": "This is the message description "
126
+ }
127
+ }
128
+ },
129
+ "examples": {
130
+ "example1": {
131
+ "value": {
132
+ "message": "Hello World!"
133
+ }
134
+ },
135
+ "example2": {
136
+ "value": {
137
+ "message": "Hello World!"
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ },
145
+ "summary": "Some resource",
146
+ "operationId": "Some resource",
147
+ "description": "",
148
+ "tags": [],
149
+ "parameters": []
150
+ }
151
+ },
152
+ "/test/attributes": {
153
+ "get": {
154
+ "responses": {
155
+ "200": {
156
+ "description": "OK",
157
+ "headers": {},
158
+ "content": {
159
+ "application/json": {
160
+ "schema": {
161
+ "oneOf": [
162
+ {
163
+ "$ref": "#/components/schemas/Message"
164
+ },
165
+ {
166
+ "$ref": "#/components/schemas/OtherMessage"
167
+ }
168
+ ]
169
+ },
170
+ "examples": {
171
+ "example1": {
172
+ "value": {
173
+ "message": "Hello World!"
174
+ }
175
+ },
176
+ "example2": {
177
+ "value": {
178
+ "message": "Hello World2"
179
+ }
180
+ },
181
+ "example3": {
182
+ "value": {
183
+ "otherMessage": "Hello World!"
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ },
191
+ "summary": "Some resource",
192
+ "operationId": "Some resource",
193
+ "description": "",
194
+ "tags": [],
195
+ "parameters": []
196
+ }
197
+ },
198
+ "/message": {
199
+ "get": {
200
+ "responses": {
201
+ "200": {
202
+ "description": "Unparsable schema should fall back to Attributes",
203
+ "headers": {},
204
+ "content": {
205
+ "application/json": {
206
+ "schema": {
207
+ "$ref": "#/components/schemas/Message"
208
+ },
209
+ "example": {
210
+ "message": ""
211
+ }
212
+ }
213
+ }
214
+ }
215
+ },
216
+ "summary": "Message",
217
+ "operationId": "Message",
218
+ "description": "",
219
+ "tags": [],
220
+ "parameters": []
221
+ }
222
+ }
223
+ },
224
+ "components": {
225
+ "schemas":{
226
+ "Message": {
227
+ "type": "object",
228
+ "properties": {
229
+ "message": {
230
+ "type": "string"
231
+ }
232
+ }
233
+ },
234
+ "OtherMessage": {
235
+ "type": "object",
236
+ "properties": {
237
+ "otherMessage": {
238
+ "type": "string"
239
+ }
240
+ }
241
+ }
242
+ }
243
+ },
244
+ "tags": []
245
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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