@team-supercharge/oasg 9.2.1 → 9.2.3

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/.gitlab-ci.yml CHANGED
@@ -19,6 +19,16 @@ commitlint:
19
19
  extends: .jarvis-commitlint
20
20
  stage: lint
21
21
 
22
+ test:
23
+ extends:
24
+ - .jarvis-on-merge-request
25
+ - .jarvis-pod-size-m
26
+ stage: lint
27
+ script:
28
+ - npm ci
29
+ - ./setup.sh
30
+ - npm test
31
+
22
32
  # release
23
33
  main-release:
24
34
  extends: .jarvis-main-release
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "editor.tabSize": 2,
3
3
  "files.trimTrailingWhitespace": true,
4
- "files.insertFinalNewline": true
4
+ "files.insertFinalNewline": true,
5
+ "cSpell.words": ["execa"]
5
6
  }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [9.2.3](https://gitlab.com/team-supercharge/oasg/compare/v9.2.2...v9.2.3) (2023-05-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * keep original sorting for merged input ([a8ae000](https://gitlab.com/team-supercharge/oasg/commit/a8ae000faf1f8cc69c6b2e55a089bae11841c309))
11
+
12
+
13
+ ### CI
14
+
15
+ * add e2e tests ([cca550c](https://gitlab.com/team-supercharge/oasg/commit/cca550c06e7f15e65262ad5829efc45178368c48))
16
+
17
+
18
+ ### Testing
19
+
20
+ * add e2e tests ([4e21e1a](https://gitlab.com/team-supercharge/oasg/commit/4e21e1a4b4aa462347e026adc9340e227726d9b2))
21
+ * add merged e2e test ([603cceb](https://gitlab.com/team-supercharge/oasg/commit/603cceb0483a1492e07bdca20466e6b69079be19))
22
+ * add more type to e2e ([cd506b1](https://gitlab.com/team-supercharge/oasg/commit/cd506b1a06d6a454899c70b90002ed9d174ec53f))
23
+
24
+ ### [9.2.2](https://gitlab.com/team-supercharge/oasg/compare/v9.2.1...v9.2.2) (2023-04-14)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * **angular:** run the npm publish in the right folder ([be32f40](https://gitlab.com/team-supercharge/oasg/commit/be32f40fffbc3f6b080c98adcca809657165b4dc))
30
+ * explicitly install deps to Docker-embedded oasg ([fb83ece](https://gitlab.com/team-supercharge/oasg/commit/fb83ecea2c8756dab942284f014fdcd695529719))
31
+
5
32
  ### [9.2.1](https://gitlab.com/team-supercharge/oasg/compare/v9.2.0...v9.2.1) (2023-04-13)
6
33
 
7
34
 
package/Dockerfile CHANGED
@@ -2,6 +2,7 @@ FROM node:18.15.0
2
2
 
3
3
  WORKDIR /app
4
4
  COPY . .
5
+ RUN npm ci
5
6
  RUN chmod +x setup.sh && ./setup.sh
6
7
 
7
8
  WORKDIR /
package/README.md CHANGED
@@ -383,7 +383,7 @@ Common target parameters
383
383
 
384
384
  ```json
385
385
  {
386
- "id": "client-react-native",
386
+ "id": "client-stubby",
387
387
  "type": "stubby",
388
388
  "source": "source-merged",
389
389
  "generateWithDocker": "true",
package/bin/merger.js CHANGED
@@ -11,7 +11,7 @@ async function merge(source) {
11
11
  fs.mkdirSync('./out');
12
12
  }
13
13
 
14
- const inputFiles = await glob(source.inputs);
14
+ const inputFiles = await getInputFilesWithGlob(source.inputs);
15
15
 
16
16
  if (inputFiles.length == 1) {
17
17
  return inputFiles[0];
@@ -29,6 +29,24 @@ async function merge(source) {
29
29
  return outFile;
30
30
  }
31
31
 
32
+ /**
33
+ * Get input files with glob while keeping the order of the input files.
34
+ * @param {string[]} inputs The input for glob.
35
+ * @returns {Promise<string[]>} The matched files.
36
+ */
37
+ async function getInputFilesWithGlob(inputs) {
38
+ /**
39
+ * @type {string[]} inputFiles
40
+ */
41
+ const inputFiles = [];
42
+ for (const input of inputs) {
43
+ const files = await glob(input);
44
+ inputFiles.push(...files);
45
+ }
46
+ const uniqueInputFiles = inputFiles.filter((value, index, self) => self.indexOf(value) === index);
47
+ return uniqueInputFiles;
48
+ }
49
+
32
50
  async function mergeDocuments(documents) {
33
51
  let finalDoc = await SwaggerParser.parse(documents[0]);
34
52
  finalDoc = resolveExternalSpecifications(documents[0], finalDoc);
@@ -0,0 +1,126 @@
1
+ {
2
+ "sources": [
3
+ {
4
+ "id": "example-simple",
5
+ "type": "simple",
6
+ "input": "example.yaml"
7
+ },
8
+ {
9
+ "id": "example-merged",
10
+ "type": "merged",
11
+ "inputs": ["*.yaml"]
12
+ }
13
+ ],
14
+ "targets": [
15
+ {
16
+ "id": "android-simple",
17
+ "type": "android",
18
+ "source": "example-simple",
19
+ "packageName": "io.supercharge.oasg.example",
20
+ "projectName": "OASgExample",
21
+ "generator": "https://gitlab.supercharge.io/misc/openapi-generator-sc/-/package_files/348/download",
22
+ "generatorCustomArgs": "-penumPropertyNaming=original -penumPropertyNaming=original -pdateLibrary=java8-localdatetime -puseCoroutines=true -pmoshiCodeGen=true",
23
+ "formatter": "0.39.0",
24
+ "formatterCustomArgs": "--disabled_rules=no-wildcard-imports,max-line-length",
25
+ "repository": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/maven"
26
+ },
27
+ {
28
+ "id": "angular-simple",
29
+ "type": "angular",
30
+ "source": "example-simple",
31
+ "repository": "https://registry.npmjs.org",
32
+ "packageName": "@test/example-source",
33
+ "generatorCustomArgs": "-pngVersion=12.0.0"
34
+ },
35
+ {
36
+ "id": "angular-merged",
37
+ "type": "angular",
38
+ "source": "example-merged",
39
+ "repository": "https://registry.npmjs.org",
40
+ "packageName": "@test/example-source",
41
+ "generatorCustomArgs": "-pngVersion=12.0.0"
42
+ },
43
+ {
44
+ "id": "swift-simple",
45
+ "type": "ios",
46
+ "source": "example-simple",
47
+ "generatorId": "swift5",
48
+ "projectName": "OASgExample",
49
+ "generator": "https://gitlab.supercharge.io/misc/openapi-generator-sc/-/package_files/348/download",
50
+ "repository": "git@gitlab.supercharge.io:example/openapi-generator-source.git",
51
+ "interfaceType": "Combine",
52
+ "generatorCustomArgs": "--model-name-suffix=ApiModel"
53
+ },
54
+ {
55
+ "id": "python-simple",
56
+ "type": "python",
57
+ "source": "example-simple",
58
+ "packageName": "oasg_example",
59
+ "repositoryUrl": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/pypi"
60
+ },
61
+ {
62
+ "id": "contract-testing-simple",
63
+ "type": "contract-testing",
64
+ "source": "example-simple",
65
+ "packageName": "@example-project/api-test",
66
+ "repository": "https://gitlab.supercharge.io/api/v4/projects/1377/packages/npm/"
67
+ },
68
+ {
69
+ "id": "server-nestjs-simple",
70
+ "type": "nestjs",
71
+ "source": "example-simple",
72
+ "packageName": "@project/oasg-example-nestjs",
73
+ "repository": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/npm/"
74
+ },
75
+ {
76
+ "id": "api-docs-simple",
77
+ "type": "openapi",
78
+ "source": "example-simple"
79
+ },
80
+ {
81
+ "id": "feign-simple",
82
+ "type": "feign",
83
+ "source": "example-simple",
84
+ "artifactId": "project-client",
85
+ "groupId": "com.project.client",
86
+ "basePackage": "com.project.client",
87
+ "mavenRepoUrl": "https://your-private-repo-url.com",
88
+ "generatorCustomArgs": "--model-name-suffix=Dto"
89
+ },
90
+ {
91
+ "id": "spring-kotlin-simple",
92
+ "type": "spring-kotlin",
93
+ "source": "example-simple",
94
+ "artifactId": "project-api",
95
+ "groupId": "com.project.api",
96
+ "basePackage": "com.project.api",
97
+ "mavenRepoUrl": "https://your-private-repo-url.com",
98
+ "generatorCustomArgs": "--model-name-suffix=Dto"
99
+ },
100
+ {
101
+ "id": "spring-simple",
102
+ "type": "spring",
103
+ "source": "example-simple",
104
+ "artifactId": "project-api",
105
+ "groupId": "com.project.api",
106
+ "basePackage": "com.project.api",
107
+ "mavenRepoUrl": "https://your-private-repo-url.com",
108
+ "generatorCustomArgs": "--model-name-suffix=Dto"
109
+ },
110
+ {
111
+ "id": "stubby-simple",
112
+ "type": "stubby",
113
+ "source": "example-simple",
114
+ "generateWithDocker": "true",
115
+ "repository": "registry.supercharge.io/misc/oasg-example",
116
+ "generator": "https://gitlab.supercharge.io/misc/openapi-generator-sc/-/package_files/225/download"
117
+ },
118
+ {
119
+ "id": "react-native-simple",
120
+ "type": "react-native",
121
+ "source": "example-simple",
122
+ "packageName": "@project/oasg-example-react-native",
123
+ "repository": "https://gitlab.supercharge.io/api/v4/projects/1226/packages/npm/"
124
+ }
125
+ ]
126
+ }
@@ -0,0 +1,722 @@
1
+ swagger: "2.0"
2
+ info:
3
+ description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
4
+ version: "1.0.0"
5
+ title: "Swagger Petstore"
6
+ termsOfService: "http://swagger.io/terms/"
7
+ contact:
8
+ email: "apiteam@swagger.io"
9
+ license:
10
+ name: "Apache 2.0"
11
+ url: "http://www.apache.org/licenses/LICENSE-2.0.html"
12
+ host: "petstore.swagger.io"
13
+ basePath: "/v2"
14
+ tags:
15
+ - name: "pet"
16
+ description: "Everything about your Pets"
17
+ externalDocs:
18
+ description: "Find out more"
19
+ url: "http://swagger.io"
20
+ - name: "store"
21
+ description: "Access to Petstore orders"
22
+ - name: "user"
23
+ description: "Operations about user"
24
+ externalDocs:
25
+ description: "Find out more about our store"
26
+ url: "http://swagger.io"
27
+ schemes:
28
+ - "https"
29
+ - "http"
30
+ paths:
31
+ /pet:
32
+ post:
33
+ tags:
34
+ - "pet"
35
+ summary: "Add a new pet to the store"
36
+ description: "a"
37
+ operationId: "addPet"
38
+ consumes:
39
+ - "application/json"
40
+ - "application/xml"
41
+ produces:
42
+ - "application/xml"
43
+ - "application/json"
44
+ parameters:
45
+ - in: "body"
46
+ name: "body"
47
+ description: "Pet object that needs to be added to the store"
48
+ required: true
49
+ schema:
50
+ $ref: "#/definitions/Pet"
51
+ responses:
52
+ "200":
53
+ description: Updated
54
+ "405":
55
+ description: "Invalid input"
56
+ security:
57
+ - petstore_auth:
58
+ - "write:pets"
59
+ - "read:pets"
60
+ put:
61
+ tags:
62
+ - "pet"
63
+ summary: "Update an existing pet"
64
+ description: "a"
65
+ operationId: "updatePet"
66
+ consumes:
67
+ - "application/json"
68
+ - "application/xml"
69
+ produces:
70
+ - "application/xml"
71
+ - "application/json"
72
+ parameters:
73
+ - in: "body"
74
+ name: "body"
75
+ description: "Pet object that needs to be added to the store"
76
+ required: true
77
+ schema:
78
+ $ref: "#/definitions/Pet"
79
+ responses:
80
+ "200":
81
+ description: Updated
82
+ "400":
83
+ description: "Invalid ID supplied"
84
+ "404":
85
+ description: "Pet not found"
86
+ "405":
87
+ description: "Validation exception"
88
+ security:
89
+ - petstore_auth:
90
+ - "write:pets"
91
+ - "read:pets"
92
+ /pet/findByStatus:
93
+ get:
94
+ tags:
95
+ - "pet"
96
+ summary: "Finds Pets by status"
97
+ description: "Multiple status values can be provided with comma separated strings"
98
+ operationId: "findPetsByStatus"
99
+ produces:
100
+ - "application/xml"
101
+ - "application/json"
102
+ parameters:
103
+ - name: "status"
104
+ in: "query"
105
+ description: "Status values that need to be considered for filter"
106
+ required: true
107
+ type: "array"
108
+ items:
109
+ type: "string"
110
+ enum:
111
+ - "available"
112
+ - "pending"
113
+ - "sold"
114
+ default: "available"
115
+ collectionFormat: "multi"
116
+ responses:
117
+ "200":
118
+ description: "successful operation"
119
+ schema:
120
+ type: "array"
121
+ items:
122
+ $ref: "#/definitions/Pet"
123
+ "400":
124
+ description: "Invalid status value"
125
+ security:
126
+ - petstore_auth:
127
+ - "write:pets"
128
+ - "read:pets"
129
+ /pet/findByTags:
130
+ get:
131
+ tags:
132
+ - "pet"
133
+ summary: "Finds Pets by tags"
134
+ description: "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."
135
+ operationId: "findPetsByTags"
136
+ produces:
137
+ - "application/xml"
138
+ - "application/json"
139
+ parameters:
140
+ - name: "tags"
141
+ in: "query"
142
+ description: "Tags to filter by"
143
+ required: true
144
+ type: "array"
145
+ items:
146
+ type: "string"
147
+ collectionFormat: "multi"
148
+ responses:
149
+ "200":
150
+ description: "successful operation"
151
+ schema:
152
+ type: "array"
153
+ items:
154
+ $ref: "#/definitions/Pet"
155
+ "400":
156
+ description: "Invalid tag value"
157
+ security:
158
+ - petstore_auth:
159
+ - "write:pets"
160
+ - "read:pets"
161
+ deprecated: true
162
+ /pet/{petId}:
163
+ get:
164
+ tags:
165
+ - "pet"
166
+ summary: "Find pet by ID"
167
+ description: "Returns a single pet"
168
+ operationId: "getPetById"
169
+ produces:
170
+ - "application/xml"
171
+ - "application/json"
172
+ parameters:
173
+ - name: "petId"
174
+ in: "path"
175
+ description: "ID of pet to return"
176
+ required: true
177
+ type: "integer"
178
+ format: "int64"
179
+ responses:
180
+ "200":
181
+ description: "successful operation"
182
+ schema:
183
+ $ref: "#/definitions/Pet"
184
+ "400":
185
+ description: "Invalid ID supplied"
186
+ "404":
187
+ description: "Pet not found"
188
+ security:
189
+ - api_key: []
190
+ post:
191
+ tags:
192
+ - "pet"
193
+ summary: "Updates a pet in the store with form data"
194
+ description: "a"
195
+ operationId: "updatePetWithForm"
196
+ consumes:
197
+ - "application/x-www-form-urlencoded"
198
+ produces:
199
+ - "application/xml"
200
+ - "application/json"
201
+ parameters:
202
+ - name: "petId"
203
+ in: "path"
204
+ description: "ID of pet that needs to be updated"
205
+ required: true
206
+ type: "integer"
207
+ format: "int64"
208
+ - name: "name"
209
+ in: "formData"
210
+ description: "Updated name of the pet"
211
+ required: false
212
+ type: "string"
213
+ - name: "status"
214
+ in: "formData"
215
+ description: "Updated status of the pet"
216
+ required: false
217
+ type: "string"
218
+ responses:
219
+ "200":
220
+ description: Updated
221
+ "405":
222
+ description: "Invalid input"
223
+ security:
224
+ - petstore_auth:
225
+ - "write:pets"
226
+ - "read:pets"
227
+ delete:
228
+ tags:
229
+ - "pet"
230
+ summary: "Deletes a pet"
231
+ description: "a"
232
+ operationId: "deletePet"
233
+ produces:
234
+ - "application/xml"
235
+ - "application/json"
236
+ parameters:
237
+ - name: "api_key"
238
+ in: "header"
239
+ required: false
240
+ type: "string"
241
+ - name: "petId"
242
+ in: "path"
243
+ description: "Pet id to delete"
244
+ required: true
245
+ type: "integer"
246
+ format: "int64"
247
+ responses:
248
+ "200":
249
+ description: Updated
250
+ "400":
251
+ description: "Invalid ID supplied"
252
+ "404":
253
+ description: "Pet not found"
254
+ security:
255
+ - petstore_auth:
256
+ - "write:pets"
257
+ - "read:pets"
258
+ /pet/{petId}/uploadImage:
259
+ post:
260
+ tags:
261
+ - "pet"
262
+ summary: "uploads an image"
263
+ description: "a"
264
+ operationId: "uploadFile"
265
+ consumes:
266
+ - "multipart/form-data"
267
+ produces:
268
+ - "application/json"
269
+ parameters:
270
+ - name: "petId"
271
+ in: "path"
272
+ description: "ID of pet to update"
273
+ required: true
274
+ type: "integer"
275
+ format: "int64"
276
+ - name: "additionalMetadata"
277
+ in: "formData"
278
+ description: "Additional data to pass to server"
279
+ required: false
280
+ type: "string"
281
+ - name: "file"
282
+ in: "formData"
283
+ description: "file to upload"
284
+ required: false
285
+ type: "file"
286
+ responses:
287
+ "200":
288
+ description: "successful operation"
289
+ schema:
290
+ $ref: "#/definitions/ApiResponse"
291
+ security:
292
+ - petstore_auth:
293
+ - "write:pets"
294
+ - "read:pets"
295
+ /store/inventory:
296
+ get:
297
+ tags:
298
+ - "store"
299
+ summary: "Returns pet inventories by status"
300
+ description: "Returns a map of status codes to quantities"
301
+ operationId: "getInventory"
302
+ produces:
303
+ - "application/json"
304
+ parameters: []
305
+ responses:
306
+ "200":
307
+ description: "successful operation"
308
+ schema:
309
+ type: "object"
310
+ additionalProperties:
311
+ type: "integer"
312
+ format: "int32"
313
+ security:
314
+ - api_key: []
315
+ /store/order:
316
+ post:
317
+ tags:
318
+ - "store"
319
+ summary: "Place an order for a pet"
320
+ description: "a"
321
+ operationId: "placeOrder"
322
+ produces:
323
+ - "application/xml"
324
+ - "application/json"
325
+ parameters:
326
+ - in: "body"
327
+ name: "body"
328
+ description: "order placed for purchasing the pet"
329
+ required: true
330
+ schema:
331
+ $ref: "#/definitions/Order"
332
+ responses:
333
+ "200":
334
+ description: "successful operation"
335
+ schema:
336
+ $ref: "#/definitions/Order"
337
+ "400":
338
+ description: "Invalid Order"
339
+ /store/order/{orderId}:
340
+ get:
341
+ tags:
342
+ - "store"
343
+ summary: "Find purchase order by ID"
344
+ description: "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions"
345
+ operationId: "getOrderById"
346
+ produces:
347
+ - "application/xml"
348
+ - "application/json"
349
+ parameters:
350
+ - name: "orderId"
351
+ in: "path"
352
+ description: "ID of pet that needs to be fetched"
353
+ required: true
354
+ type: "integer"
355
+ maximum: 10.0
356
+ minimum: 1.0
357
+ format: "int64"
358
+ responses:
359
+ "200":
360
+ description: "successful operation"
361
+ schema:
362
+ $ref: "#/definitions/Order"
363
+ "400":
364
+ description: "Invalid ID supplied"
365
+ "404":
366
+ description: "Order not found"
367
+ delete:
368
+ tags:
369
+ - "store"
370
+ summary: "Delete purchase order by ID"
371
+ description: "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors"
372
+ operationId: "deleteOrder"
373
+ produces:
374
+ - "application/xml"
375
+ - "application/json"
376
+ parameters:
377
+ - name: "orderId"
378
+ in: "path"
379
+ description: "ID of the order that needs to be deleted"
380
+ required: true
381
+ type: "integer"
382
+ minimum: 1.0
383
+ format: "int64"
384
+ responses:
385
+ "200":
386
+ description: Updated
387
+ "400":
388
+ description: "Invalid ID supplied"
389
+ "404":
390
+ description: "Order not found"
391
+ /user:
392
+ post:
393
+ tags:
394
+ - "user"
395
+ summary: "Create user"
396
+ description: "This can only be done by the logged in user."
397
+ operationId: "createUser"
398
+ produces:
399
+ - "application/xml"
400
+ - "application/json"
401
+ parameters:
402
+ - in: "body"
403
+ name: "body"
404
+ description: "Created user object"
405
+ required: true
406
+ schema:
407
+ $ref: "#/definitions/User"
408
+ responses:
409
+ "200":
410
+ description: Updated
411
+ default:
412
+ description: "successful operation"
413
+ /user/createWithArray:
414
+ post:
415
+ tags:
416
+ - "user"
417
+ summary: "Creates list of users with given input array"
418
+ description: "a"
419
+ operationId: "createUsersWithArrayInput"
420
+ produces:
421
+ - "application/xml"
422
+ - "application/json"
423
+ parameters:
424
+ - in: "body"
425
+ name: "body"
426
+ description: "List of user object"
427
+ required: true
428
+ schema:
429
+ type: "array"
430
+ items:
431
+ $ref: "#/definitions/User"
432
+ responses:
433
+ "200":
434
+ description: Updated
435
+ default:
436
+ description: "successful operation"
437
+ /user/createWithList:
438
+ post:
439
+ tags:
440
+ - "user"
441
+ summary: "Creates list of users with given input array"
442
+ description: "a"
443
+ operationId: "createUsersWithListInput"
444
+ produces:
445
+ - "application/xml"
446
+ - "application/json"
447
+ parameters:
448
+ - in: "body"
449
+ name: "body"
450
+ description: "List of user object"
451
+ required: true
452
+ schema:
453
+ type: "array"
454
+ items:
455
+ $ref: "#/definitions/User"
456
+ responses:
457
+ "200":
458
+ description: Updated
459
+ default:
460
+ description: "successful operation"
461
+ /user/login:
462
+ get:
463
+ tags:
464
+ - "user"
465
+ summary: "Logs user into the system"
466
+ description: "a"
467
+ operationId: "loginUser"
468
+ produces:
469
+ - "application/xml"
470
+ - "application/json"
471
+ parameters:
472
+ - name: "username"
473
+ in: "query"
474
+ description: "The user name for login"
475
+ required: true
476
+ type: "string"
477
+ - name: "password"
478
+ in: "query"
479
+ description: "The password for login in clear text"
480
+ required: true
481
+ type: "string"
482
+ responses:
483
+ "200":
484
+ description: "successful operation"
485
+ schema:
486
+ type: "string"
487
+ headers:
488
+ X-Rate-Limit:
489
+ type: "integer"
490
+ format: "int32"
491
+ description: "calls per hour allowed by the user"
492
+ X-Expires-After:
493
+ type: "string"
494
+ format: "date-time"
495
+ description: "date in UTC when token expires"
496
+ "400":
497
+ description: "Invalid username/password supplied"
498
+ /user/logout:
499
+ get:
500
+ tags:
501
+ - "user"
502
+ summary: "Logs out current logged in user session"
503
+ description: "a"
504
+ operationId: "logoutUser"
505
+ produces:
506
+ - "application/xml"
507
+ - "application/json"
508
+ parameters: []
509
+ responses:
510
+ "200":
511
+ description: Updated
512
+ default:
513
+ description: "successful operation"
514
+ /user/{username}:
515
+ get:
516
+ tags:
517
+ - "user"
518
+ summary: "Get user by user name"
519
+ description: "a"
520
+ operationId: "getUserByName"
521
+ produces:
522
+ - "application/xml"
523
+ - "application/json"
524
+ parameters:
525
+ - name: "username"
526
+ in: "path"
527
+ description: "The name that needs to be fetched. Use user1 for testing. "
528
+ required: true
529
+ type: "string"
530
+ responses:
531
+ "200":
532
+ description: "successful operation"
533
+ schema:
534
+ $ref: "#/definitions/User"
535
+ "400":
536
+ description: "Invalid username supplied"
537
+ "404":
538
+ description: "User not found"
539
+ put:
540
+ tags:
541
+ - "user"
542
+ summary: "Updated user"
543
+ description: "This can only be done by the logged in user."
544
+ operationId: "updateUser"
545
+ produces:
546
+ - "application/xml"
547
+ - "application/json"
548
+ parameters:
549
+ - name: "username"
550
+ in: "path"
551
+ description: "name that need to be updated"
552
+ required: true
553
+ type: "string"
554
+ - in: "body"
555
+ name: "body"
556
+ description: "Updated user object"
557
+ required: true
558
+ schema:
559
+ $ref: "#/definitions/User"
560
+ responses:
561
+ "200":
562
+ description: Updated
563
+ "400":
564
+ description: "Invalid user supplied"
565
+ "404":
566
+ description: "User not found"
567
+ delete:
568
+ tags:
569
+ - "user"
570
+ summary: "Delete user"
571
+ description: "This can only be done by the logged in user."
572
+ operationId: "deleteUser"
573
+ produces:
574
+ - "application/xml"
575
+ - "application/json"
576
+ parameters:
577
+ - name: "username"
578
+ in: "path"
579
+ description: "The name that needs to be deleted"
580
+ required: true
581
+ type: "string"
582
+ responses:
583
+ "200":
584
+ description: Updated
585
+ "400":
586
+ description: "Invalid username supplied"
587
+ "404":
588
+ description: "User not found"
589
+ securityDefinitions:
590
+ petstore_auth:
591
+ type: "oauth2"
592
+ authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
593
+ flow: "implicit"
594
+ scopes:
595
+ write:pets: "modify pets in your account"
596
+ read:pets: "read your pets"
597
+ api_key:
598
+ type: "apiKey"
599
+ name: "api_key"
600
+ in: "header"
601
+ definitions:
602
+ Order:
603
+ type: "object"
604
+ properties:
605
+ id:
606
+ type: "integer"
607
+ format: "int64"
608
+ petId:
609
+ type: "integer"
610
+ format: "int64"
611
+ quantity:
612
+ type: "integer"
613
+ format: "int32"
614
+ shipDate:
615
+ type: "string"
616
+ format: "date-time"
617
+ status:
618
+ type: "string"
619
+ description: "Order Status"
620
+ enum:
621
+ - "placed"
622
+ - "approved"
623
+ - "delivered"
624
+ complete:
625
+ type: "boolean"
626
+ default: false
627
+ xml:
628
+ name: "Order"
629
+ Category:
630
+ type: "object"
631
+ properties:
632
+ id:
633
+ type: "integer"
634
+ format: "int64"
635
+ name:
636
+ type: "string"
637
+ xml:
638
+ name: "Category"
639
+ User:
640
+ type: "object"
641
+ properties:
642
+ id:
643
+ type: "integer"
644
+ format: "int64"
645
+ username:
646
+ type: "string"
647
+ firstName:
648
+ type: "string"
649
+ lastName:
650
+ type: "string"
651
+ email:
652
+ type: "string"
653
+ password:
654
+ type: "string"
655
+ phone:
656
+ type: "string"
657
+ userStatus:
658
+ type: "integer"
659
+ format: "int32"
660
+ description: "User Status"
661
+ xml:
662
+ name: "User"
663
+ Tag:
664
+ type: "object"
665
+ properties:
666
+ id:
667
+ type: "integer"
668
+ format: "int64"
669
+ name:
670
+ type: "string"
671
+ xml:
672
+ name: "Tag"
673
+ Pet:
674
+ type: "object"
675
+ required:
676
+ - "name"
677
+ - "photoUrls"
678
+ properties:
679
+ id:
680
+ type: "integer"
681
+ format: "int64"
682
+ category:
683
+ $ref: "#/definitions/Category"
684
+ name:
685
+ type: "string"
686
+ example: "doggie"
687
+ photoUrls:
688
+ type: "array"
689
+ xml:
690
+ name: "photoUrl"
691
+ wrapped: true
692
+ items:
693
+ type: "string"
694
+ tags:
695
+ type: "array"
696
+ xml:
697
+ name: "tag"
698
+ wrapped: true
699
+ items:
700
+ $ref: "#/definitions/Tag"
701
+ status:
702
+ type: "string"
703
+ description: "pet status in the store"
704
+ enum:
705
+ - "available"
706
+ - "pending"
707
+ - "sold"
708
+ xml:
709
+ name: "Pet"
710
+ ApiResponse:
711
+ type: "object"
712
+ properties:
713
+ code:
714
+ type: "integer"
715
+ format: "int32"
716
+ type:
717
+ type: "string"
718
+ message:
719
+ type: "string"
720
+ externalDocs:
721
+ description: "Find out more about Swagger"
722
+ url: "http://swagger.io"
@@ -0,0 +1,105 @@
1
+ const execa = require("execa");
2
+ const { createTestProject, projectDir } = require("./setup.js");
3
+ const { copy } = require("fs-extra");
4
+ const path = require("path");
5
+
6
+ describe("oasg", () => {
7
+ beforeAll(async () => {
8
+ await createTestProject();
9
+ await copy(
10
+ path.join(__dirname, "__tests__", "config.json"),
11
+ path.join(projectDir, "config.json")
12
+ );
13
+ await copy(
14
+ path.join(__dirname, "__tests__", "example.yaml"),
15
+ path.join(projectDir, "example.yaml")
16
+ );
17
+ }, 120000);
18
+
19
+
20
+ it("should lint", async () => {
21
+ await execa("npx", ["oasg", "lint"], {
22
+ cwd: projectDir,
23
+ });
24
+ }, 120000);
25
+
26
+
27
+ it("should generate android-simple", async () => {
28
+ await execa("npx", ["oasg", "generate", "android-simple"], {
29
+ cwd: projectDir,
30
+ });
31
+ }, 120000);
32
+
33
+ it("should generate angular-simple", async () => {
34
+ await execa("npx", ["oasg", "generate", "angular-simple"], {
35
+ cwd: projectDir,
36
+ });
37
+ }, 120000);
38
+
39
+ it("should generate angular-merged", async () => {
40
+ await execa("npx", ["oasg", "generate", "angular-merged"], {
41
+ cwd: projectDir,
42
+ });
43
+ }, 120000);
44
+
45
+ it("should generate swift-simple", async () => {
46
+ await execa("npx", ["oasg", "generate", "swift-simple"], {
47
+ cwd: projectDir,
48
+ });
49
+ }, 120000);
50
+
51
+ it.skip("should generate python-simple", async () => {
52
+ await execa("npx", ["oasg", "generate", "python-simple"], {
53
+ cwd: projectDir,
54
+ });
55
+ }, 120000);
56
+
57
+ it.skip("should generate contract-testing-simple", async () => {
58
+ await execa("npx", ["oasg", "generate", "contract-testing-simple"], {
59
+ cwd: projectDir,
60
+ });
61
+ }, 120000);
62
+
63
+ it.skip("should generate server-nestjs-simple", async () => {
64
+ await execa("npx", ["oasg", "generate", "server-nestjs-simple"], {
65
+ cwd: projectDir,
66
+ });
67
+ }, 120000);
68
+
69
+ it.skip("should generate api-docs-simple", async () => {
70
+ await execa("npx", ["oasg", "generate", "api-docs-simple"], {
71
+ cwd: projectDir,
72
+ });
73
+ }, 120000);
74
+
75
+ it.skip("should generate feign-simple", async () => {
76
+ await execa("npx", ["oasg", "generate", "feign-simple"], {
77
+ cwd: projectDir,
78
+ });
79
+ }, 180000);
80
+
81
+ it("should generate spring-kotlin-simple", async () => {
82
+ await execa("npx", ["oasg", "generate", "spring-kotlin-simple"], {
83
+ cwd: projectDir,
84
+ });
85
+ }, 240000);
86
+
87
+ it("should generate spring-simple", async () => {
88
+ await execa("npx", ["oasg", "generate", "spring-simple"], {
89
+ cwd: projectDir,
90
+ });
91
+ }, 240000);
92
+
93
+ it.skip("should generate stubby-simple", async () => {
94
+ await execa("npx", ["oasg", "generate", "stubby-simple"], {
95
+ cwd: projectDir,
96
+ });
97
+ }, 120000);
98
+
99
+ it("should generate react-native-simple", async () => {
100
+ await execa("npx", ["oasg", "generate", "react-native-simple"], {
101
+ cwd: projectDir,
102
+ });
103
+ }, 120000);
104
+
105
+ });
package/e2e/setup.js ADDED
@@ -0,0 +1,21 @@
1
+ const execa = require("execa");
2
+ const fs = require("fs-extra");
3
+ const path = require("path");
4
+
5
+ const oasgDir = path.join(__dirname, "..");
6
+ const projectDir = path.join(oasgDir, "tmp/test-project");
7
+
8
+
9
+ module.exports = {
10
+ createTestProject: async () => {
11
+ await fs.remove(projectDir);
12
+ await fs.ensureDir(projectDir);
13
+ await execa("npm", ["init", "-y"], {
14
+ cwd: projectDir,
15
+ });
16
+ await execa("npm", ["install", `@team-supercharge/oasg@${oasgDir}`], {
17
+ cwd: projectDir,
18
+ });
19
+ },
20
+ projectDir,
21
+ };
package/jest.config.js ADDED
@@ -0,0 +1,195 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ module.exports = {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/private/var/folders/v2/20bc64b97vb267khhr8dmqc00000gn/T/jest_dx",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ // clearMocks: false,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ // collectCoverage: false,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ // coverageDirectory: undefined,
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ coverageProvider: "v8",
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ // coverageThreshold: undefined,
46
+
47
+ // A path to a custom dependency extractor
48
+ // dependencyExtractor: undefined,
49
+
50
+ // Make calling deprecated APIs throw helpful error messages
51
+ // errorOnDeprecated: false,
52
+
53
+ // The default configuration for fake timers
54
+ // fakeTimers: {
55
+ // "enableGlobally": false
56
+ // },
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ // globalSetup: undefined,
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ // moduleDirectories: [
75
+ // "node_modules"
76
+ // ],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "mjs",
82
+ // "cjs",
83
+ // "jsx",
84
+ // "ts",
85
+ // "tsx",
86
+ // "json",
87
+ // "node"
88
+ // ],
89
+
90
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
91
+ // moduleNameMapper: {},
92
+
93
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
94
+ // modulePathIgnorePatterns: [],
95
+
96
+ // Activates notifications for test results
97
+ // notify: false,
98
+
99
+ // An enum that specifies notification mode. Requires { notify: true }
100
+ // notifyMode: "failure-change",
101
+
102
+ // A preset that is used as a base for Jest's configuration
103
+ // preset: undefined,
104
+
105
+ // Run tests from one or more projects
106
+ // projects: undefined,
107
+
108
+ // Use this configuration option to add custom reporters to Jest
109
+ // reporters: undefined,
110
+
111
+ // Automatically reset mock state before every test
112
+ // resetMocks: false,
113
+
114
+ // Reset the module registry before running each individual test
115
+ // resetModules: false,
116
+
117
+ // A path to a custom resolver
118
+ // resolver: undefined,
119
+
120
+ // Automatically restore mock state and implementation before every test
121
+ // restoreMocks: false,
122
+
123
+ // The root directory that Jest should scan for tests and modules within
124
+ // rootDir: undefined,
125
+
126
+ // A list of paths to directories that Jest should use to search for files in
127
+ // roots: [
128
+ // "<rootDir>"
129
+ // ],
130
+
131
+ // Allows you to use a custom runner instead of Jest's default test runner
132
+ // runner: "jest-runner",
133
+
134
+ // The paths to modules that run some code to configure or set up the testing environment before each test
135
+ // setupFiles: [],
136
+
137
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
138
+ // setupFilesAfterEnv: [],
139
+
140
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
141
+ // slowTestThreshold: 5,
142
+
143
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
144
+ // snapshotSerializers: [],
145
+
146
+ // The test environment that will be used for testing
147
+ // testEnvironment: "jest-environment-node",
148
+
149
+ // Options that will be passed to the testEnvironment
150
+ // testEnvironmentOptions: {},
151
+
152
+ // Adds a location field to test results
153
+ // testLocationInResults: false,
154
+
155
+ // The glob patterns Jest uses to detect test files
156
+ // testMatch: [
157
+ // "**/__tests__/**/*.[jt]s?(x)",
158
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
159
+ // ],
160
+
161
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
162
+ // testPathIgnorePatterns: [
163
+ // "/node_modules/"
164
+ // ],
165
+
166
+ // The regexp pattern or array of patterns that Jest uses to detect test files
167
+ // testRegex: [],
168
+
169
+ // This option allows the use of a custom results processor
170
+ // testResultsProcessor: undefined,
171
+
172
+ // This option allows use of a custom test runner
173
+ // testRunner: "jest-circus/runner",
174
+
175
+ // A map from regular expressions to paths to transformers
176
+ // transform: undefined,
177
+
178
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
179
+ // transformIgnorePatterns: [
180
+ // "/node_modules/",
181
+ // "\\.pnp\\.[^\\/]+$"
182
+ // ],
183
+
184
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
185
+ // unmockedModulePathPatterns: undefined,
186
+
187
+ // Indicates whether each individual test should be reported during the run
188
+ // verbose: undefined,
189
+
190
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
191
+ // watchPathIgnorePatterns: [],
192
+
193
+ // Whether to use watchman for file crawling
194
+ // watchman: true,
195
+ };
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "9.2.1",
3
+ "version": "9.2.3",
4
4
  "description": "Node-based tool to lint OpenAPI documents and generate clients, servers and documentation from them",
5
5
  "author": "Supercharge",
6
6
  "license": "MIT",
7
- "scripts": {},
7
+ "scripts": {
8
+ "test": "jest"
9
+ },
8
10
  "bin": {
9
11
  "oasg": "./bin/oasg"
10
12
  },
@@ -34,5 +36,10 @@
34
36
  "swagger-ui-express": "^4.1.4",
35
37
  "yamljs": "^0.3.0",
36
38
  "yargs": "^16.0.3"
39
+ },
40
+ "devDependencies": {
41
+ "execa": "^5.0.0",
42
+ "fs-extra": "^11.1.1",
43
+ "jest": "^29.5.0"
37
44
  }
38
45
  }
package/setup.sh CHANGED
File without changes
@@ -2,9 +2,6 @@
2
2
 
3
3
  source $(dirname "$0")/../common.sh
4
4
 
5
- cd out/$targetId
6
- # need to publish dist directory
5
+ cd out/$targetId/dist
7
6
  npm publish \
8
- dist \
9
7
  $(if [[ "$preRelease" == "true" ]]; then echo "--tag next"; fi)
10
- cd ../..