@trapi/swagger 0.2.11 → 0.2.15

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 (58) hide show
  1. package/dist/config/utils/index.d.ts +1 -1
  2. package/dist/config/utils/validator.d.ts +2 -2
  3. package/dist/config/utils/validator.d.ts.map +1 -1
  4. package/dist/config/utils/validator.js +9 -9
  5. package/dist/config/utils/validator.js.map +1 -1
  6. package/dist/metadata.d.ts +1 -1
  7. package/dist/metadata.d.ts.map +1 -1
  8. package/dist/specification/abstract.d.ts +5 -5
  9. package/dist/specification/abstract.d.ts.map +1 -1
  10. package/dist/specification/abstract.js +23 -27
  11. package/dist/specification/abstract.js.map +1 -1
  12. package/dist/specification/index.d.ts +1 -1
  13. package/dist/specification/type.d.ts +0 -3
  14. package/dist/specification/type.d.ts.map +1 -1
  15. package/dist/specification/type.js.map +1 -1
  16. package/dist/specification/utils.d.ts +3 -3
  17. package/dist/specification/utils.d.ts.map +1 -1
  18. package/dist/specification/utils.js +1 -1
  19. package/dist/specification/utils.js.map +1 -1
  20. package/dist/specification/v2/index.d.ts +3 -3
  21. package/dist/specification/v2/index.d.ts.map +1 -1
  22. package/dist/specification/v2/index.js +48 -60
  23. package/dist/specification/v2/index.js.map +1 -1
  24. package/dist/specification/v2/type.d.ts +1 -1
  25. package/dist/specification/v2/type.d.ts.map +1 -1
  26. package/dist/specification/v3/index.d.ts +3 -3
  27. package/dist/specification/v3/index.d.ts.map +1 -1
  28. package/dist/specification/v3/index.js +28 -36
  29. package/dist/specification/v3/index.js.map +1 -1
  30. package/dist/specification/v3/type.d.ts +1 -1
  31. package/dist/specification/v3/type.d.ts.map +1 -1
  32. package/dist/utils.d.ts +3 -3
  33. package/dist/utils.d.ts.map +1 -1
  34. package/dist/utils.js +1 -1
  35. package/dist/utils.js.map +1 -1
  36. package/package.json +12 -9
  37. package/src/config/index.ts +0 -8
  38. package/src/config/utils/index.ts +0 -8
  39. package/src/config/utils/validator.ts +0 -94
  40. package/src/index.ts +0 -12
  41. package/src/metadata.ts +0 -58
  42. package/src/specification/abstract.ts +0 -250
  43. package/src/specification/index.ts +0 -11
  44. package/src/specification/type.ts +0 -328
  45. package/src/specification/utils.ts +0 -47
  46. package/src/specification/v2/index.ts +0 -463
  47. package/src/specification/v2/type.ts +0 -92
  48. package/src/specification/v3/index.ts +0 -448
  49. package/src/specification/v3/type.ts +0 -129
  50. package/src/type.ts +0 -14
  51. package/src/utils.ts +0 -28
  52. package/test/data/metadata.json +0 -1
  53. package/test/jest.config.js +0 -43
  54. package/test/tsconfig.json +0 -28
  55. package/test/unit/index.ts +0 -425
  56. package/tsconfig.build.json +0 -11
  57. package/tsconfig.json +0 -9
  58. package/writable/.gitignore +0 -3
@@ -1,425 +0,0 @@
1
- /*
2
- * Copyright (c) 2021.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- import {GeneratorOutput} from "@trapi/metadata";
9
- import {createSpecGenerator, Version3SpecGenerator} from "../../src";
10
-
11
- const jsonata = require('jsonata');
12
-
13
- const metadata : GeneratorOutput = require('../data/metadata.json');
14
-
15
- const specGenerator = createSpecGenerator(metadata, {
16
- host: 'http://localhost:3000/'
17
- });
18
-
19
- const spec = specGenerator.getSwaggerSpec();
20
-
21
- describe(`generating swagger spec from metadata`, () => {
22
- it('should generate paths for decorated services', () => {
23
- expect(spec.paths).toHaveProperty('/mypath');
24
- expect(spec.paths).toHaveProperty('/mypath/secondpath');
25
- });
26
-
27
- it('should generate paths for decorated services, declared on superclasses', () => {
28
- expect(spec.paths).toHaveProperty('/promise');
29
- expect(spec.paths).toHaveProperty('/promise/{id}');
30
- });
31
-
32
- it('should generate examples for object parameter', () => {
33
- expect(spec.paths).toHaveProperty('/mypath/secondpath');
34
- const expression = jsonata('paths."/mypath/secondpath".get.responses."200".examples."application/json".name');
35
- expect(expression.evaluate(spec)).toEqual('Joe');
36
- });
37
-
38
- it('should generate examples for array parameter', () => {
39
- expect(spec.paths).toHaveProperty('/mypath');
40
- const expression = jsonata('paths."/mypath".post.responses."200".examples."application/json".name');
41
- expect(expression.evaluate(spec)).toEqual('Joe');
42
- });
43
-
44
- it('should generate optional parameters for params with question marks or default initializers', () => {
45
- let expression = jsonata('paths."/mypath/secondpath".get.parameters[0].required');
46
- expect(expression.evaluate(spec)).toEqual(true);
47
- expression = jsonata('paths."/mypath/secondpath".get.parameters[1].required');
48
- expect(expression.evaluate(spec)).toEqual(false);
49
- expression = jsonata('paths."/mypath/secondpath".get.parameters[2].required');
50
- expect(expression.evaluate(spec)).toEqual(false);
51
- expression = jsonata('paths."/mypath/secondpath".get.parameters[3]');
52
- const evaluate = expression.evaluate(spec);
53
- expect(evaluate.schema).toHaveProperty('$ref');
54
- expect(evaluate.schema.$ref).toEqual("#/definitions/TestEnum");
55
- });
56
-
57
- it('should generate specs for enum params based on it values types', () => {
58
- let expression = jsonata('paths."/mypath/secondpath".get.parameters[3]');
59
- let paramSpec = expression.evaluate(spec);
60
- expect(paramSpec.schema).toHaveProperty('$ref');
61
- expect(paramSpec.schema.$ref).toEqual('#/definitions/TestEnum');
62
- expect(paramSpec.in).toEqual('query');
63
-
64
- expression = jsonata('paths."/mypath/secondpath".get.parameters[4]');
65
- paramSpec = expression.evaluate(spec);
66
- expect(paramSpec.schema).toHaveProperty('$ref');
67
- expect(paramSpec.schema.$ref).toEqual('#/definitions/TestNumericEnum');
68
- expect(paramSpec.in).toEqual('query');
69
-
70
- expression = jsonata('paths."/mypath/secondpath".get.parameters[5]');
71
- paramSpec = expression.evaluate(spec);
72
-
73
- expect(paramSpec.schema.$ref).toEqual('#/definitions/TestMixedEnum');
74
- });
75
-
76
- it('should generate description for methods and parameters', () => {
77
- let expression = jsonata('paths."/mypath/secondpath".get.parameters[0].description');
78
- expect(expression.evaluate(spec)).toEqual('This is the test param description');
79
- expression = jsonata('paths."/mypath/secondpath".get.description');
80
- expect(expression.evaluate(spec)).toEqual('This is the method description');
81
- });
82
-
83
- it('should support multiple response decorators', () => {
84
- let expression = jsonata('paths."/mypath".get.responses."400".description');
85
- expect(expression.evaluate(spec)).toEqual('The request format was incorrect.');
86
- expression = jsonata('paths."/mypath".get.responses."500".description');
87
- expect(expression.evaluate(spec)).toEqual('There was an unexpected error.');
88
- expression = jsonata('paths."/mypath/secondpath".get.responses."200".description');
89
- expect(expression.evaluate(spec)).toEqual('The success test.');
90
- expression = jsonata('paths."/mypath/secondpath".get.responses."200".schema."$ref"');
91
- expect(expression.evaluate(spec)).toEqual('#/definitions/Person');
92
- expression = jsonata('paths."/mypath/secondpath".get.responses."200".examples."application/json"[0].name');
93
- expect(expression.evaluate(spec)).toEqual('Joe');
94
- });
95
-
96
- it('should include default response if a non-conflicting response is declared with a decorator', () => {
97
- let expression = jsonata('paths."/promise".get.responses');
98
- expect(Object.keys(expression.evaluate(spec)).length).toEqual(2);
99
- expression = jsonata('paths."/promise".get.responses."200".description');
100
- expect(expression.evaluate(spec)).toEqual('Ok');
101
- expression = jsonata('paths."/promise".get.responses."401".description');
102
- expect(expression.evaluate(spec)).toEqual('Unauthorized');
103
- });
104
-
105
- it('should not include default response if it conflicts with a declared response', () => {
106
- let expression = jsonata('paths."/promise".post.responses');
107
- expect(Object.keys(expression.evaluate(spec)).length).toEqual(3); // todo: originally 2
108
- expression = jsonata('paths."/promise".post.responses."201".description');
109
- expect(expression.evaluate(spec)).toEqual('Person Created');
110
- expression = jsonata('paths."/promise".post.responses."201".examples."application/json".name');
111
- expect(expression.evaluate(spec)).toEqual('Test Person');
112
- expression = jsonata('paths."/promise".post.responses."401".description');
113
- expect(expression.evaluate(spec)).toEqual('Unauthorized');
114
- });
115
-
116
- it('should update a declared response with the declared default response example if response annotation doesn\'t specify one', () => {
117
- let expression = jsonata('paths."/promise/{id}".get.responses');
118
- expect(Object.keys(expression.evaluate(spec)).length).toEqual(2);
119
- expression = jsonata('paths."/promise/{id}".get.responses."200".description');
120
- expect(expression.evaluate(spec)).toEqual('All Good');
121
- expression = jsonata('paths."/promise/{id}".get.responses."200".examples."application/json".name');
122
- expect(expression.evaluate(spec)).toEqual('Test Person');
123
- expression = jsonata('paths."/promise/{id}".get.responses."401".description');
124
- expect(expression.evaluate(spec)).toEqual('Unauthorized');
125
- });
126
-
127
- it('should generate a definition with a referenced type', () => {
128
- const expression = jsonata('definitions.Person.properties.address."$ref"');
129
- expect(expression.evaluate(spec)).toEqual('#/definitions/Address');
130
- });
131
-
132
- it('should generate a body param with string schema type', () => {
133
- let expression = jsonata('paths."/mypath".post.parameters[0].in');
134
- expect(expression.evaluate(spec)).toEqual('body');
135
- expression = jsonata('paths."/mypath".post.parameters[0].name');
136
- expect(expression.evaluate(spec)).toEqual('body');
137
- expression = jsonata('paths."/mypath".post.parameters[0].schema.type');
138
- expect(expression.evaluate(spec)).toEqual('string');
139
- });
140
-
141
- it('should generate a body param with object schema type', () => {
142
- let expression = jsonata('paths."/mypath/obj".post.parameters[0].name');
143
- expect(expression.evaluate(spec)).toEqual('data');
144
- expression = jsonata('paths."/mypath/obj".post.parameters[0].schema.type');
145
- expect(expression.evaluate(spec)).toEqual('object');
146
- });
147
-
148
- it('should generate a query param with array type', () => {
149
- const param = jsonata('paths."/mypath/multi-query".get.parameters[0]').evaluate(spec);
150
- expect(param.name).toEqual('id');
151
- expect(param.required).toEqual(true);
152
- expect(param.type).toEqual('array');
153
- expect(param.items).toBeDefined();
154
- expect(param.items.type).toEqual('string');
155
- expect(param.collectionFormat).toEqual('multi');
156
- });
157
-
158
- it('should generate an array query param for parameter with compatible array and primitive intersection type', () => {
159
- const param = jsonata('paths."/mypath/multi-query".get.parameters[1]').evaluate(spec);
160
- expect(param.name).toEqual('name');
161
- expect(param.required).toEqual(false);
162
- expect(param.type).toEqual('string'); // its union type of Array<string> and string -> object
163
- // expect(param.items).toBeDefined();
164
- // expect(param.items.type).toEqual('string');
165
- // expect(param.collectionFormat).toEqual('multi');
166
- });
167
-
168
- it('should generate default value for a number query param', () => {
169
- const param = jsonata('paths."/mypath/default-query".get.parameters[0]').evaluate(spec);
170
- expect(param.name).toEqual('num');
171
- expect(param.required).toEqual(false);
172
- expect(param.type).toEqual('number');
173
- expect(param.default).toEqual(5);
174
- });
175
-
176
- it('should generate default value for a string query param', () => {
177
- const param = jsonata('paths."/mypath/default-query".get.parameters[1]').evaluate(spec);
178
- expect(param.name).toEqual('str');
179
- expect(param.required).toEqual(false);
180
- expect(param.type).toEqual('string');
181
- expect(param.default).toEqual('default value');
182
- });
183
-
184
- it('should generate default value for a true boolean query param', () => {
185
- const param = jsonata('paths."/mypath/default-query".get.parameters[2]').evaluate(spec);
186
- expect(param.name).toEqual('bool1');
187
- expect(param.required).toEqual(false);
188
- expect(param.type).toEqual('boolean');
189
- expect(param.default).toEqual(true);
190
- });
191
-
192
- it('should generate default value for a false boolean query param', () => {
193
- const param = jsonata('paths."/mypath/default-query".get.parameters[3]').evaluate(spec);
194
- expect(param.name).toEqual('bool2');
195
- expect(param.required).toEqual(false);
196
- expect(param.type).toEqual('boolean');
197
- expect(param.default).toEqual(false);
198
- });
199
-
200
- it('should generate default value for a string array query param', () => {
201
- const param = jsonata('paths."/mypath/default-query".get.parameters[4]').evaluate(spec);
202
- expect(param.name).toEqual('arr');
203
- expect(param.required).toEqual(false);
204
- expect(param.type).toEqual('array');
205
- expect(param.items).toBeDefined();
206
- expect(param.items.type).toEqual('string');
207
- expect(param.default).toStrictEqual(['a', 'b', 'c']);
208
- });
209
- });
210
-
211
- describe('TypeEndpoint', () => {
212
- it('should generate definitions for type aliases', () => {
213
- expect(spec.paths).toHaveProperty('/type/{param}');
214
- let expression = jsonata('definitions.SimpleHelloType.properties.greeting.description');
215
- expect(expression.evaluate(spec)).toEqual('Description for greeting property');
216
-
217
- expression = jsonata('definitions.UUID');
218
- expect(expression.evaluate(spec)).toEqual({
219
- description: undefined,
220
- default: undefined,
221
- example: undefined,
222
- format: undefined,
223
- type: 'string',
224
- });
225
- });
226
-
227
- it('should generate nested object types in definitions', () => {
228
- let expression = jsonata('definitions.SimpleHelloType.properties.profile.type');
229
- expect(expression.evaluate(spec)).toEqual('object');
230
- expression = jsonata('definitions.SimpleHelloType.properties.profile.description');
231
- expect(expression.evaluate(spec)).toEqual('Description for profile');
232
- expression = jsonata('definitions.SimpleHelloType.properties.profile.properties.name.type');
233
- expect(expression.evaluate(spec)).toEqual('string');
234
- expression = jsonata('definitions.SimpleHelloType.properties.profile.properties.name.description');
235
- expect(expression.evaluate(spec)).toEqual('Description for profile name');
236
- });
237
-
238
- it('should ignore properties that are functions', () => {
239
- const expression = jsonata('definitions.SimpleHelloType.properties.comparePassword');
240
- expect(expression.evaluate(spec)).toBeDefined(); // todo: fix
241
- });
242
-
243
- it('should support compilerOptions', () => {
244
- let expression = jsonata('definitions.TestInterface');
245
- expect(expression.evaluate(spec)).toEqual({
246
- description: undefined,
247
- properties: {
248
- a: { type: 'string', description: undefined },
249
- b: { type: 'number', format: 'double', description: undefined }
250
- },
251
- required: ['a', 'b'],
252
- type: 'object',
253
- });
254
- expect(spec.paths).toHaveProperty('/mypath/test-compiler-options');
255
- expression = jsonata('paths."/mypath/test-compiler-options".post.responses."200".schema');
256
- expect(expression.evaluate(spec)).toEqual({ $ref: '#/definitions/TestInterface' });
257
- expression = jsonata('paths."/mypath/test-compiler-options".post.parameters[0].schema');
258
- expect(expression.evaluate(spec)).toEqual({ $ref: '#/definitions/TestInterface' });
259
- });
260
- /*
261
- it('should support formparam', () => {
262
- expect(spec.paths).toHaveProperty('/mypath/test-form-param');
263
- let expression = jsonata('paths."/mypath/test-form-param".post.responses."200".schema');
264
- expect(expression.evaluate(spec)).toEqual({ type: 'string' });
265
- expression = jsonata('paths."/mypath/test-form-param".post.parameters[0]');
266
- expect(expression.evaluate(spec)).toEqual({
267
- description: '',
268
- in: 'formData',
269
- name: 'id',
270
- required: true,
271
- type: 'string',
272
- });
273
- });
274
-
275
- */
276
- });
277
-
278
- describe('PrimitiveEndpoint', () => {
279
- it('should generate integer type for @IsInt decorator declared on class property', () => {
280
- let expression = jsonata('definitions.PrimitiveClassModel.properties.int.type');
281
- expect(expression.evaluate(spec)).toEqual('integer');
282
- expression = jsonata('definitions.PrimitiveClassModel.properties.int.format');
283
- expect(expression.evaluate(spec)).toEqual('int32');
284
- expression = jsonata('definitions.PrimitiveClassModel.properties.int.description');
285
- expect(expression.evaluate(spec)).toEqual('An integer');
286
- });
287
-
288
- it('should generate integer type for @IsLong decorator declared on class property', () => {
289
- let expression = jsonata('definitions.PrimitiveClassModel.properties.long.type');
290
- expect(expression.evaluate(spec)).toEqual('integer');
291
- expression = jsonata('definitions.PrimitiveClassModel.properties.long.format');
292
- expect(expression.evaluate(spec)).toEqual('int64');
293
- expression = jsonata('definitions.PrimitiveClassModel.properties.long.description');
294
- expect(expression.evaluate(spec)).toEqual(undefined);
295
- });
296
-
297
- it('should generate number type for @IsFloat decorator declared on class property', () => {
298
- let expression = jsonata('definitions.PrimitiveClassModel.properties.float.type');
299
- expect(expression.evaluate(spec)).toEqual('number');
300
- expression = jsonata('definitions.PrimitiveClassModel.properties.float.format');
301
- expect(expression.evaluate(spec)).toEqual('float');
302
- expression = jsonata('definitions.PrimitiveClassModel.properties.float.description');
303
- expect(expression.evaluate(spec)).toEqual(undefined);
304
- });
305
-
306
- it('should generate number type for @IsDouble decorator declared on class property', () => {
307
- let expression = jsonata('definitions.PrimitiveClassModel.properties.double.type');
308
- expect(expression.evaluate(spec)).toEqual('number');
309
- expression = jsonata('definitions.PrimitiveClassModel.properties.double.format');
310
- expect(expression.evaluate(spec)).toEqual('double');
311
- expression = jsonata('definitions.PrimitiveClassModel.properties.double.description');
312
- expect(expression.evaluate(spec)).toEqual(undefined);
313
- });
314
-
315
- it('should generate integer type for jsdoc @IsInt tag on interface property', () => {
316
- let expression = jsonata('definitions.PrimitiveInterfaceModel.properties.int.type');
317
- expect(expression.evaluate(spec)).toEqual('integer');
318
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.int.format');
319
- expect(expression.evaluate(spec)).toEqual('int32');
320
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.int.description');
321
- expect(expression.evaluate(spec)).toEqual('An integer');
322
- });
323
-
324
- it('should generate integer type for jsdoc @IsLong tag on interface property', () => {
325
- let expression = jsonata('definitions.PrimitiveInterfaceModel.properties.long.type');
326
- expect(expression.evaluate(spec)).toEqual('integer');
327
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.long.format');
328
- expect(expression.evaluate(spec)).toEqual('int64');
329
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.long.description');
330
- expect(expression.evaluate(spec)).toEqual(undefined);
331
- });
332
-
333
- it('should generate number type for jsdoc @IsFloat tag on interface property', () => {
334
- let expression = jsonata('definitions.PrimitiveInterfaceModel.properties.float.type');
335
- expect(expression.evaluate(spec)).toEqual('number');
336
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.float.format');
337
- expect(expression.evaluate(spec)).toEqual('float');
338
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.float.description');
339
- expect(expression.evaluate(spec)).toEqual(undefined);
340
- });
341
-
342
- it('should generate number type for jsdoc @IsDouble tag on interface property', () => {
343
- let expression = jsonata('definitions.PrimitiveInterfaceModel.properties.double.type');
344
- expect(expression.evaluate(spec)).toEqual('number');
345
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.double.format');
346
- expect(expression.evaluate(spec)).toEqual('double');
347
- expression = jsonata('definitions.PrimitiveInterfaceModel.properties.double.description');
348
- expect(expression.evaluate(spec)).toEqual(undefined);
349
- });
350
-
351
- it('should generate number type decorated path params', () => {
352
- let expression = jsonata('paths."/primitives/{id}".get.parameters[0].type');
353
- expect(expression.evaluate(spec)).toEqual('integer');
354
- expression = jsonata('paths."/primitives/{id}".get.parameters[0].format');
355
- expect(expression.evaluate(spec)).toEqual('int64');
356
- });
357
-
358
- it('should generate array type names as type + Array', () => {
359
- let expression = jsonata('definitions.ResponseBodystringArray');
360
- expect(expression.evaluate(spec)).toBeUndefined();
361
- expression = jsonata('paths."/primitives/arrayNative".get.responses."200".schema."$ref"');
362
- expect(expression.evaluate(spec)).toEqual('#/definitions/ResponseBodystringarray');
363
- expression = jsonata('paths."/primitives/array".get.responses."200".schema."$ref"');
364
- expect(expression.evaluate(spec)).toEqual('#/definitions/ResponseBodystringarray');
365
- });
366
- });
367
-
368
- describe('ParameterizedEndpoint', () => {
369
- it('should generate path param for params declared on class', () => {
370
- const expression = jsonata('paths."/parameterized/{objectId}/test".get.parameters[0].in');
371
- expect(expression.evaluate(spec)).toEqual('path');
372
- });
373
- });
374
-
375
- describe('AbstractEntityEndpoint', () => {
376
- it('should not duplicate inherited properties in the required list', () => {
377
- const expression = jsonata('definitions.NamedEntity.required');
378
- expect(expression.evaluate(spec)).toStrictEqual(['id', 'name']);
379
- });
380
-
381
- it('should use property description from base class if not defined in child', () => {
382
- const expression = jsonata('definitions.NamedEntity.properties.id.description');
383
- expect(expression.evaluate(spec)).toEqual('A numeric identifier');
384
- });
385
- });
386
-
387
- describe('ResponseController', () => {
388
- it('should support multiple response decorators on controller', () => {
389
- let expression = jsonata('paths."/response".get.responses."400".description');
390
- expect(expression.evaluate(spec)).toEqual('The request format was incorrect.');
391
- expression = jsonata('paths."/response".get.responses."500".description');
392
- expect(expression.evaluate(spec)).toEqual('There was an unexpected error.');
393
- });
394
-
395
- it('should support decorators on controller and method', () => {
396
- let expression = jsonata('paths."/response/test".get.responses."400".description');
397
- expect(expression.evaluate(spec)).toEqual('The request format was incorrect.');
398
- expression = jsonata('paths."/response/test".get.responses."500".description');
399
- expect(expression.evaluate(spec)).toEqual('There was an unexpected error.');
400
- expression = jsonata('paths."/response/test".get.responses."502".description');
401
- expect(expression.evaluate(spec)).toEqual('Internal server error.');
402
- expression = jsonata('paths."/response/test".get.responses."401".description');
403
- expect(expression.evaluate(spec)).toEqual('Unauthorized.');
404
- });
405
- });
406
-
407
- describe('SpecGenerator', () => {
408
- it('should be able to generate open api 3.0 outputs', async () => {
409
- const openapi = await new Version3SpecGenerator(specGenerator.getMetaData(), {}).getSwaggerSpec();
410
- expect(openapi.openapi).toEqual('3.0.0');
411
- });
412
- });
413
-
414
- describe('TestUnionType', () => {
415
- it('should support union types', () => {
416
- const expression = jsonata('paths."/unionTypes".post.parameters[0]');
417
- const paramSpec = expression.evaluate(spec);
418
- const definitionExpression = jsonata('definitions.MyTypeWithUnion.properties.property');
419
- const myTypeDefinition = definitionExpression.evaluate(spec);
420
- expect(paramSpec.schema.$ref).toEqual('#/definitions/MyTypeWithUnion');
421
- expect(myTypeDefinition.type).toEqual('string');
422
- expect(myTypeDefinition.enum).toEqual(['value1', 'value2']);
423
- });
424
- });
425
-
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.build.json",
3
-
4
- "compilerOptions": {
5
- "outDir": "./dist"
6
- },
7
-
8
- "include": [
9
- "src/**/*.ts"
10
- ]
11
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "paths": {
5
- "@trapi-metadata/utils": ["./packages/trapi-metadata-utils/src"],
6
- "@trapi/metadata": ["./packages/trapi-metadata/src"]
7
- }
8
- }
9
- }
@@ -1,3 +0,0 @@
1
- *
2
- */
3
- !.gitignore