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.
Files changed (117) hide show
  1. package/.github/workflows/codeql-analysis.yml +71 -0
  2. package/.github/workflows/docker-publish.yml +70 -0
  3. package/.github/workflows/nodejs.yml +26 -0
  4. package/.travis.yml +3 -5
  5. package/Dockerfile +5 -0
  6. package/LICENSE +0 -0
  7. package/README.md +31 -5
  8. package/bin/apib2swagger.js +43 -17
  9. package/index.js +92 -374
  10. package/package.json +6 -4
  11. package/src/escape_json_pointer.js +0 -0
  12. package/src/mson_to_json_schema.js +13 -8
  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 +24 -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 +1 -0
  46. package/test/output/01. Simplest API.ref.json +1 -0
  47. package/test/output/02. Resource and Actions.json +2 -0
  48. package/test/output/02. Resource and Actions.ref.json +2 -0
  49. package/test/output/03. Named Resource and Actions.json +2 -0
  50. package/test/output/03. Named Resource and Actions.ref.json +2 -0
  51. package/test/output/04. Grouping Resources.json +2 -0
  52. package/test/output/04. Grouping Resources.ref.json +2 -0
  53. package/test/output/05. Responses.json +7 -1
  54. package/test/output/05. Responses.ref.json +7 -1
  55. package/test/output/06. Requests.json +9 -3
  56. package/test/output/06. Requests.ref.json +9 -3
  57. package/test/output/07. Parameters.json +12 -5
  58. package/test/output/07. Parameters.ref.json +12 -5
  59. package/test/output/08. Attributes.json +1 -0
  60. package/test/output/08. Attributes.ref.json +1 -0
  61. package/test/output/09. Advanced Attributes.json +3 -0
  62. package/test/output/09. Advanced Attributes.ref.json +3 -0
  63. package/test/output/10. Data Structures.json +3 -0
  64. package/test/output/10. Data Structures.ref.json +3 -0
  65. package/test/output/11. Resource Model.json +7 -1
  66. package/test/output/11. Resource Model.ref.json +7 -1
  67. package/test/output/12. Advanced Action.json +3 -0
  68. package/test/output/12. Advanced Action.ref.json +3 -0
  69. package/test/output/13. Named Endpoints.json +12 -2
  70. package/test/output/13. Named Endpoints.ref.json +12 -2
  71. package/test/output/Attributes.json +1 -0
  72. package/test/output/Attributes.ref.json +1 -0
  73. package/test/output/Gist Fox API + Auth.json +47 -7
  74. package/test/output/Gist Fox API + Auth.ref.json +47 -7
  75. package/test/output/Issue-#15.json +3 -0
  76. package/test/output/Issue-#15.ref.json +3 -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 +1 -0
  80. package/test/output/Issue-#23.ref.json +1 -0
  81. package/test/output/Issue-#26.json +2 -0
  82. package/test/output/Issue-#26.ref.json +2 -0
  83. package/test/output/Issue-#29.json +2 -0
  84. package/test/output/Issue-#29.ref.json +2 -0
  85. package/test/output/Issue-#33.json +9 -8
  86. package/test/output/Issue-#33.ref.json +9 -8
  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 +1 -0
  90. package/test/output/Issue-#36.ref.json +1 -0
  91. package/test/output/Issue-#38.bearer.json +53 -52
  92. package/test/output/Issue-#38.json +1 -0
  93. package/test/output/Issue-#38.ref.json +1 -0
  94. package/test/output/Issue-#49.json +141 -0
  95. package/test/output/Issue-#49.ref.json +126 -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 +3 -0
  107. package/test/output/Schema.ref.json +3 -0
  108. package/test/output/apiblueprint_uber.json +5 -0
  109. package/test/output/apiblueprint_uber.ref.json +5 -0
  110. package/test/output/apiblueprint_valid_simple.json +47 -7
  111. package/test/output/apiblueprint_valid_simple.ref.json +47 -7
  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 +31 -15
  116. package/test/util.test.js +151 -0
  117. package/.npmignore +0 -35
@@ -1,56 +1,57 @@
1
1
  {
2
- "swagger": "2.0",
3
- "info": {
4
- "title": "",
5
- "version": "",
6
- "description": ""
7
- },
8
- "paths": {
9
- "/whatever": {
10
- "get": {
11
- "responses": {
12
- "200": {
13
- "description": "OK",
14
- "headers": {},
15
- "examples": {}
16
- }
2
+ "swagger": "2.0",
3
+ "info": {
4
+ "title": "",
5
+ "version": "",
6
+ "description": ""
7
+ },
8
+ "paths": {
9
+ "/whatever": {
10
+ "get": {
11
+ "responses": {
12
+ "200": {
13
+ "description": "OK",
14
+ "headers": {},
15
+ "examples": {}
16
+ }
17
+ },
18
+ "summary": "Whatever",
19
+ "operationId": "Whatever",
20
+ "description": "",
21
+ "tags": [],
22
+ "parameters": [
23
+ {
24
+ "name": "limit",
25
+ "in": "query",
26
+ "description": "The maximum number of results to return.",
27
+ "required": false,
28
+ "type": "number",
29
+ "default": 10
30
+ }
31
+ ],
32
+ "security": [
33
+ {
34
+ "basic": []
17
35
  },
18
- "summary": "Whatever",
19
- "description": "",
20
- "tags": [],
21
- "parameters": [
22
- {
23
- "name": "limit",
24
- "in": "query",
25
- "description": "The maximum number of results to return.",
26
- "required": false,
27
- "type": "number",
28
- "default": 10
29
- }
30
- ],
31
- "security": [
32
- {
33
- "basic": []
34
- },
35
- {
36
- "bearer": []
37
- }
38
- ]
39
- }
40
- }
41
- },
42
- "definitions": {
43
- "Whatever": {}
44
- },
45
- "securityDefinitions": {
46
- "basic": {
47
- "type": "basic"
48
- },
49
- "bearer": {
50
- "in": "header",
51
- "name": "Authorization",
52
- "type": "apiKey"
36
+ {
37
+ "bearer": []
38
+ }
39
+ ]
53
40
  }
41
+ }
42
+ },
43
+ "definitions": {
44
+ "Whatever": {}
45
+ },
46
+ "securityDefinitions": {
47
+ "basic": {
48
+ "type": "basic"
54
49
  },
55
- "tags": []
56
- }
50
+ "bearer": {
51
+ "type": "apiKey",
52
+ "in": "header",
53
+ "name": "Authorization"
54
+ }
55
+ },
56
+ "tags": []
57
+ }
@@ -16,6 +16,7 @@
16
16
  }
17
17
  },
18
18
  "summary": "Whatever",
19
+ "operationId": "Whatever",
19
20
  "description": "",
20
21
  "tags": [],
21
22
  "parameters": [
@@ -16,6 +16,7 @@
16
16
  }
17
17
  },
18
18
  "summary": "Whatever",
19
+ "operationId": "Whatever",
19
20
  "description": "",
20
21
  "tags": [],
21
22
  "parameters": [
@@ -0,0 +1,141 @@
1
+ {
2
+ "swagger": "2.0",
3
+ "info": {
4
+ "title": "",
5
+ "version": "",
6
+ "description": ""
7
+ },
8
+ "paths": {
9
+ "/user": {
10
+ "get": {
11
+ "responses": {
12
+ "200": {
13
+ "description": "OK",
14
+ "headers": {},
15
+ "examples": {
16
+ "application/json": {
17
+ "id": "",
18
+ "name": null
19
+ }
20
+ },
21
+ "schema": {
22
+ "type": "object",
23
+ "properties": {
24
+ "id": {
25
+ "type": "string"
26
+ },
27
+ "name": {
28
+ "type": [
29
+ "string",
30
+ "null"
31
+ ]
32
+ }
33
+ },
34
+ "required": [
35
+ "id",
36
+ "name"
37
+ ]
38
+ }
39
+ },
40
+ "500": {
41
+ "description": "Internal Server Error",
42
+ "headers": {},
43
+ "examples": {}
44
+ }
45
+ },
46
+ "summary": "Get one user",
47
+ "operationId": "Get one user",
48
+ "description": "",
49
+ "tags": [
50
+ "Users"
51
+ ],
52
+ "parameters": [],
53
+ "produces": [
54
+ "application/json"
55
+ ]
56
+ }
57
+ },
58
+ "/users": {
59
+ "get": {
60
+ "responses": {
61
+ "200": {
62
+ "description": "OK",
63
+ "headers": {},
64
+ "examples": {
65
+ "application/json": [
66
+ {
67
+ "id": "",
68
+ "name": null
69
+ }
70
+ ]
71
+ },
72
+ "schema": {
73
+ "type": "array",
74
+ "items": {}
75
+ }
76
+ },
77
+ "500": {
78
+ "description": "Internal Server Error",
79
+ "headers": {},
80
+ "examples": {}
81
+ }
82
+ },
83
+ "summary": "Get a collection of users",
84
+ "operationId": "Get a collection of users",
85
+ "description": "",
86
+ "tags": [
87
+ "Users"
88
+ ],
89
+ "parameters": [],
90
+ "produces": [
91
+ "application/json"
92
+ ]
93
+ }
94
+ }
95
+ },
96
+ "definitions": {
97
+ "A user": {},
98
+ "Some users": {},
99
+ "User": {
100
+ "type": "object",
101
+ "required": [
102
+ "id",
103
+ "name"
104
+ ],
105
+ "properties": {
106
+ "id": {
107
+ "type": "string"
108
+ },
109
+ "name": {
110
+ "type": [
111
+ "string",
112
+ "null"
113
+ ]
114
+ }
115
+ }
116
+ },
117
+ "Users": {
118
+ "type": "object",
119
+ "required": [
120
+ "users"
121
+ ],
122
+ "properties": {
123
+ "users": {
124
+ "type": [
125
+ "array",
126
+ "null"
127
+ ],
128
+ "items": {
129
+ "$ref": "#/definitions/User"
130
+ }
131
+ }
132
+ }
133
+ }
134
+ },
135
+ "securityDefinitions": {},
136
+ "tags": [
137
+ {
138
+ "name": "Users"
139
+ }
140
+ ]
141
+ }
@@ -0,0 +1,126 @@
1
+ {
2
+ "swagger": "2.0",
3
+ "info": {
4
+ "title": "",
5
+ "version": "",
6
+ "description": ""
7
+ },
8
+ "paths": {
9
+ "/user": {
10
+ "get": {
11
+ "responses": {
12
+ "200": {
13
+ "description": "OK",
14
+ "headers": {},
15
+ "examples": {
16
+ "application/json": {
17
+ "id": "",
18
+ "name": null
19
+ }
20
+ },
21
+ "schema": {
22
+ "$ref": "#/definitions/User"
23
+ }
24
+ },
25
+ "500": {
26
+ "description": "Internal Server Error",
27
+ "headers": {},
28
+ "examples": {}
29
+ }
30
+ },
31
+ "summary": "Get one user",
32
+ "operationId": "Get one user",
33
+ "description": "",
34
+ "tags": [
35
+ "Users"
36
+ ],
37
+ "parameters": [],
38
+ "produces": [
39
+ "application/json"
40
+ ]
41
+ }
42
+ },
43
+ "/users": {
44
+ "get": {
45
+ "responses": {
46
+ "200": {
47
+ "description": "OK",
48
+ "headers": {},
49
+ "examples": {
50
+ "application/json": [
51
+ {
52
+ "id": "",
53
+ "name": null
54
+ }
55
+ ]
56
+ },
57
+ "schema": {
58
+ "type": "array",
59
+ "items": {}
60
+ }
61
+ },
62
+ "500": {
63
+ "description": "Internal Server Error",
64
+ "headers": {},
65
+ "examples": {}
66
+ }
67
+ },
68
+ "summary": "Get a collection of users",
69
+ "operationId": "Get a collection of users",
70
+ "description": "",
71
+ "tags": [
72
+ "Users"
73
+ ],
74
+ "parameters": [],
75
+ "produces": [
76
+ "application/json"
77
+ ]
78
+ }
79
+ }
80
+ },
81
+ "definitions": {
82
+ "A user": {},
83
+ "Some users": {},
84
+ "User": {
85
+ "type": "object",
86
+ "required": [
87
+ "id",
88
+ "name"
89
+ ],
90
+ "properties": {
91
+ "id": {
92
+ "type": "string"
93
+ },
94
+ "name": {
95
+ "type": [
96
+ "string",
97
+ "null"
98
+ ]
99
+ }
100
+ }
101
+ },
102
+ "Users": {
103
+ "type": "object",
104
+ "required": [
105
+ "users"
106
+ ],
107
+ "properties": {
108
+ "users": {
109
+ "type": [
110
+ "array",
111
+ "null"
112
+ ],
113
+ "items": {
114
+ "$ref": "#/definitions/User"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ },
120
+ "securityDefinitions": {},
121
+ "tags": [
122
+ {
123
+ "name": "Users"
124
+ }
125
+ ]
126
+ }
@@ -0,0 +1,199 @@
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
+ "/object": {
15
+ "get": {
16
+ "responses": {
17
+ "200": {
18
+ "description": "OK",
19
+ "headers": {},
20
+ "content": {
21
+ "application/json": {
22
+ "schema": {
23
+ "oneOf": [
24
+ {
25
+ "type": "object",
26
+ "properties": {
27
+ "message": {
28
+ "type": "string"
29
+ }
30
+ }
31
+ },
32
+ {
33
+ "type": "object",
34
+ "properties": {
35
+ "otherMessage": {
36
+ "type": "string"
37
+ },
38
+ "someNum": {
39
+ "type": "number"
40
+ }
41
+ }
42
+ }
43
+ ]
44
+ },
45
+ "examples": {
46
+ "example1": {
47
+ "value": {
48
+ "message": ""
49
+ }
50
+ },
51
+ "example2": {
52
+ "value": {
53
+ "otherMessage": "",
54
+ "someNum": 0
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ },
62
+ "summary": "Some resource",
63
+ "operationId": "Some resource",
64
+ "description": "",
65
+ "tags": [],
66
+ "parameters": []
67
+ }
68
+ },
69
+ "/array/object": {
70
+ "post": {
71
+ "responses": {
72
+ "200": {
73
+ "description": "OK",
74
+ "headers": {},
75
+ "content": {
76
+ "application/json": {
77
+ "schema": {
78
+ "type": "array",
79
+ "items": {
80
+ "type": "object",
81
+ "properties": {
82
+ "path": {
83
+ "type": "string"
84
+ },
85
+ "otherMessage": {
86
+ "type": "object",
87
+ "properties": {
88
+ "otherMessage": {
89
+ "type": "string"
90
+ },
91
+ "someNum": {
92
+ "type": "number"
93
+ }
94
+ }
95
+ }
96
+ },
97
+ "required": [
98
+ "path"
99
+ ]
100
+ }
101
+ },
102
+ "example": [
103
+ {
104
+ "path": "/files",
105
+ "otherMessage": {
106
+ "otherMessage": "",
107
+ "someNum": 0
108
+ }
109
+ }
110
+ ]
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "summary": "Some resource",
116
+ "operationId": "Some resource",
117
+ "description": "",
118
+ "tags": [],
119
+ "parameters": [],
120
+ "requestBody": {
121
+ "content": {
122
+ "application/json": {
123
+ "example": {
124
+ "message": ""
125
+ },
126
+ "schema": {
127
+ "type": "object",
128
+ "properties": {
129
+ "message": {
130
+ "type": "string"
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ },
139
+ "/messages": {
140
+ "get": {
141
+ "responses": {
142
+ "200": {
143
+ "description": "OK",
144
+ "headers": {},
145
+ "content": {
146
+ "application/json": {
147
+ "schema": {
148
+ "type": "array",
149
+ "items": {
150
+ "type": "object",
151
+ "properties": {
152
+ "message": {
153
+ "type": "string"
154
+ }
155
+ }
156
+ }
157
+ },
158
+ "example": [
159
+ {
160
+ "message": ""
161
+ }
162
+ ]
163
+ }
164
+ }
165
+ }
166
+ },
167
+ "summary": "Some resource",
168
+ "operationId": "Some resource",
169
+ "description": "",
170
+ "tags": [],
171
+ "parameters": []
172
+ }
173
+ }
174
+ },
175
+ "components": {
176
+ "schemas": {
177
+ "Message": {
178
+ "type": "object",
179
+ "properties": {
180
+ "message": {
181
+ "type": "string"
182
+ }
183
+ }
184
+ },
185
+ "OtherMessage": {
186
+ "type": "object",
187
+ "properties": {
188
+ "otherMessage": {
189
+ "type": "string"
190
+ },
191
+ "someNum": {
192
+ "type": "number"
193
+ }
194
+ }
195
+ }
196
+ }
197
+ },
198
+ "tags": []
199
+ }