@trayio/tray-openapi 3.8.1-beta → 3.9.1

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.
@@ -44,6 +44,8 @@ const GenerateOperationJson_1 = require("./file-generators/GenerateOperationJson
44
44
  const GenerateInputSchema_1 = require("./file-generators/types/GenerateInputSchema");
45
45
  const OpenApiSchemaTransformer_1 = require("./OpenApiSchemaTransformer");
46
46
  class OpenApiSchemaImporter {
47
+ generator;
48
+ fileStorage;
47
49
  constructor(generator, fileStorage) {
48
50
  this.generator = generator;
49
51
  this.fileStorage = fileStorage;
@@ -64,9 +66,15 @@ class OpenApiSchemaImporter {
64
66
  const flatOperations = operation.flat();
65
67
  const buildConnectorResponse = flatOperations.reduce((acc, curr) => {
66
68
  if (curr.tag === 'error') {
67
- return Object.assign(Object.assign({}, acc), { errors: [...acc.errors, curr] });
69
+ return {
70
+ ...acc,
71
+ errors: [...acc.errors, curr],
72
+ };
68
73
  }
69
- return Object.assign(Object.assign({}, acc), { successes: [...acc.successes, curr] });
74
+ return {
75
+ ...acc,
76
+ successes: [...acc.successes, curr],
77
+ };
70
78
  }, { successes: [], errors: [] });
71
79
  return buildConnectorResponse;
72
80
  }));
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  const NodeFsGenerator_1 = require("@trayio/generator/generator/NodeFsGenerator");
36
27
  const FakeFileStorage_1 = require("@trayio/commons/file/FakeFileStorage");
@@ -45,17 +36,17 @@ describe('openApiSchemaImporter', () => {
45
36
  const openApiSchemaImporter = new OpenApiSchemaImporter_1.OpenApiSchemaImporter(generator, fileStorage);
46
37
  let result;
47
38
  const spec = 'test-openapi-spec.json';
48
- beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
39
+ beforeAll(async () => {
49
40
  fileStorage.write({
50
41
  key: `${__dirname}/${spec}`,
51
42
  metadata: { name: spec },
52
43
  content: stream_1.Readable.from(Buffer.from(JSON.stringify(openApiSpec))),
53
44
  });
54
- result = yield openApiSchemaImporter.buildConnector(`${__dirname}/${spec}`, 'testConnector')();
55
- }));
56
- afterAll(() => __awaiter(void 0, void 0, void 0, function* () {
57
- yield fs.rm(`${process.cwd()}/test/`, { recursive: true, force: true });
58
- }));
45
+ result = await openApiSchemaImporter.buildConnector(`${__dirname}/${spec}`, 'testConnector')();
46
+ });
47
+ afterAll(async () => {
48
+ await fs.rm(`${process.cwd()}/test/`, { recursive: true, force: true });
49
+ });
59
50
  it('should import successfully', () => {
60
51
  const buildConnectorResponse = E.getOrElse((error) => {
61
52
  console.error(error);
@@ -57,12 +57,12 @@ const mergePathLevelParamsIntoHttpMethod = (openApiSpec) => {
57
57
  return methodAcc;
58
58
  }
59
59
  const parameters = (0, exports.getMergedParameters)(pathValue, httpMethodValue);
60
- methodAcc[httpMethodName] = Object.assign(Object.assign({}, httpMethodValue), { parameters });
60
+ methodAcc[httpMethodName] = { ...httpMethodValue, parameters };
61
61
  return methodAcc;
62
62
  }, {});
63
63
  pathAcc[pathName] = updatedPathValue;
64
64
  return pathAcc;
65
65
  }, {});
66
- return E.right(Object.assign(Object.assign({}, openApiSpec), { paths }));
66
+ return E.right({ ...openApiSpec, paths });
67
67
  };
68
68
  exports.mergePathLevelParamsIntoHttpMethod = mergePathLevelParamsIntoHttpMethod;
@@ -26,7 +26,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const E = __importStar(require("fp-ts/Either"));
27
27
  const O = __importStar(require("fp-ts/Option"));
28
28
  const GenerateHandler_1 = require("./GenerateHandler");
29
- const getGenerateHandlerInput = (input) => (Object.assign({ connectorNamePascalCase: 'OpenApiTest', operationNamePascalCase: 'GetPhoto', operationNameCamelCase: 'getPhoto', httpMethod: 'get', baseUrl: 'https://jsonplaceholder.typicode.com', input: {
29
+ const getGenerateHandlerInput = (input) => ({
30
+ connectorNamePascalCase: 'OpenApiTest',
31
+ operationNamePascalCase: 'GetPhoto',
32
+ operationNameCamelCase: 'getPhoto',
33
+ httpMethod: 'get',
34
+ baseUrl: 'https://jsonplaceholder.typicode.com',
35
+ input: {
30
36
  title: O.none,
31
37
  properties: O.none,
32
38
  additionalProperties: O.none,
@@ -37,7 +43,10 @@ const getGenerateHandlerInput = (input) => (Object.assign({ connectorNamePascalC
37
43
  not: O.none,
38
44
  in: O.none,
39
45
  type: O.none,
40
- }, httpPath: '/photos' }, input));
46
+ },
47
+ httpPath: '/photos',
48
+ ...input,
49
+ });
41
50
  describe('GenerateHandler', () => {
42
51
  it('it should generate a handler with no inputs', () => {
43
52
  const payload = getGenerateHandlerInput({});
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  const E = __importStar(require("fp-ts/Either"));
36
27
  const FakeFileStorage_1 = require("@trayio/commons/file/FakeFileStorage");
@@ -38,13 +29,13 @@ const O = __importStar(require("fp-ts/Option"));
38
29
  const GenerateOperationJson_1 = require("./GenerateOperationJson");
39
30
  describe('generateOperationJson', () => {
40
31
  const fileStorage = new FakeFileStorage_1.FakeFileStorage();
41
- it('should generate operation.json file', () => __awaiter(void 0, void 0, void 0, function* () {
32
+ it('should generate operation.json file', async () => {
42
33
  const writeSpy = jest.spyOn(fileStorage, 'write');
43
34
  const operationDirPath = '/path/to/operation';
44
35
  const operationNameSnakeCase = 'get_photo';
45
36
  const operationNameKebabCase = 'get-photo';
46
37
  const operationDescription = 'Get photo operation';
47
- const result = yield (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription)();
38
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription)();
48
39
  if (E.isLeft(result)) {
49
40
  throw new Error('expected result to be right');
50
41
  }
@@ -55,13 +46,13 @@ describe('generateOperationJson', () => {
55
46
  }, O.none);
56
47
  expect(result.right).toBeUndefined();
57
48
  expect(fileStorage.files.has('/path/to/operation/operation.json')).toEqual(true);
58
- }));
59
- it('should generate correct data for operation.json', () => __awaiter(void 0, void 0, void 0, function* () {
49
+ });
50
+ it('should generate correct data for operation.json', async () => {
60
51
  const operationDirPath = '/path/to/operation';
61
52
  const operationNameSnakeCase = 'get_photo';
62
53
  const operationNameKebabCase = 'get-photo';
63
54
  const operationDescription = 'Get photo operation';
64
- const result = yield (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription)();
55
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription)();
65
56
  if (E.isLeft(result)) {
66
57
  throw new Error('expected result to be right');
67
58
  }
@@ -74,5 +65,5 @@ describe('generateOperationJson', () => {
74
65
  title: 'get-photo',
75
66
  description: 'Get photo operation',
76
67
  }));
77
- }));
68
+ });
78
69
  });
@@ -44,7 +44,10 @@ const mergeRequired = (params, body) => {
44
44
  const mergeParamsAndBody = (params, body) => ({
45
45
  title: O.none,
46
46
  type: O.some('object'),
47
- properties: O.some(Object.assign(Object.assign({}, (O.isSome(body.properties) && body.properties.value)), (O.isSome(params.properties) && params.properties.value))),
47
+ properties: O.some({
48
+ ...(O.isSome(body.properties) && body.properties.value),
49
+ ...(O.isSome(params.properties) && params.properties.value),
50
+ }),
48
51
  required: O.some(mergeRequired(params, body)),
49
52
  additionalProperties: O.some(false),
50
53
  allOf: O.none,
@@ -59,8 +62,14 @@ const transformInput = (parameters) => {
59
62
  parameters.forEach((parameter) => {
60
63
  const codecWithNullValueRemoval = CompositeCodec_1.CompositeCodec.fromCodecs(OpenApiCodecs_1.parameterSchemaCodec, RemoveNullValuesCodec_1.RemoveNullValuesCodec.instance);
61
64
  const parameterWithNoOptions = codecWithNullValueRemoval.encode(parameter);
62
- const parameterWithJsdocAnnotation = Object.assign(Object.assign({}, parameterWithNoOptions), { description: `@description ${parameter.description}` });
63
- const decodedParam = OpenApiTypeDescriptors_1.schemaObjectTypeDescriptor.decode(Object.assign(Object.assign({}, (0, openapi_schema_to_json_schema_1.fromParameter)(parameterWithJsdocAnnotation)), { in: parameter.in }));
65
+ const parameterWithJsdocAnnotation = {
66
+ ...parameterWithNoOptions,
67
+ description: `@description ${parameter.description}`,
68
+ };
69
+ const decodedParam = OpenApiTypeDescriptors_1.schemaObjectTypeDescriptor.decode({
70
+ ...(0, openapi_schema_to_json_schema_1.fromParameter)(parameterWithJsdocAnnotation),
71
+ in: parameter.in,
72
+ });
64
73
  if (decodedParam._tag === 'Left') {
65
74
  throw new Error('Failed to decode params');
66
75
  }
@@ -86,8 +95,17 @@ const transformInput = (parameters) => {
86
95
  * OpenAPI spec's body params don't have an .in property, we add one in here since query, path, and header params do
87
96
  */
88
97
  const appendInPropertyToBody = (body) => O.fold(() => body, (properties) => {
89
- const propsWithInBody = Object.keys(properties).reduce((acc, name) => (Object.assign(Object.assign({}, acc), { [name]: Object.assign(Object.assign({}, properties[name]), { in: O.some('body') }) })), {});
90
- return Object.assign(Object.assign({}, body), { properties: O.some(propsWithInBody) });
98
+ const propsWithInBody = Object.keys(properties).reduce((acc, name) => ({
99
+ ...acc,
100
+ [name]: {
101
+ ...properties[name],
102
+ in: O.some('body'),
103
+ },
104
+ }), {});
105
+ return {
106
+ ...body,
107
+ properties: O.some(propsWithInBody),
108
+ };
91
109
  })(body.properties);
92
110
  const blankOutputSchema = () => ({
93
111
  title: O.none,
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  const E = __importStar(require("fp-ts/Either"));
36
27
  const TE = __importStar(require("fp-ts/TaskEither"));
@@ -38,7 +29,7 @@ const O = __importStar(require("fp-ts/Option"));
38
29
  const GenerateInputSchema_1 = require("./GenerateInputSchema");
39
30
  const GenerateInputTypes_1 = require("./GenerateInputTypes");
40
31
  describe('GenerateInputSchema', () => {
41
- it('it should process an endpoint with path and query string parameters and generate input.ts file contents', () => __awaiter(void 0, void 0, void 0, function* () {
32
+ it('it should process an endpoint with path and query string parameters and generate input.ts file contents', async () => {
42
33
  const endpoint = {
43
34
  operationId: 'getPost',
44
35
  description: '',
@@ -92,7 +83,7 @@ describe('GenerateInputSchema', () => {
92
83
  throw new Error('Should have been right');
93
84
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
94
85
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
95
- const generatedInputFile = yield TE.getOrElse((error) => {
86
+ const generatedInputFile = await TE.getOrElse((error) => {
96
87
  throw new Error('Should have been right');
97
88
  })(inputTypes)();
98
89
  const expectedInputFile = `export interface GetPostInput {
@@ -107,8 +98,8 @@ describe('GenerateInputSchema', () => {
107
98
  }
108
99
  `;
109
100
  expect(generatedInputFile).toEqual(expectedInputFile);
110
- }));
111
- it('it should process an endpoint with body parameters and generate input.ts file contents', () => __awaiter(void 0, void 0, void 0, function* () {
101
+ });
102
+ it('it should process an endpoint with body parameters and generate input.ts file contents', async () => {
112
103
  const endpoint = {
113
104
  operationId: 'createPost',
114
105
  description: 'Create a new post',
@@ -187,7 +178,7 @@ describe('GenerateInputSchema', () => {
187
178
  throw new Error('Should have been right');
188
179
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
189
180
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
190
- const generatedInputFile = yield TE.getOrElse((error) => {
181
+ const generatedInputFile = await TE.getOrElse((error) => {
191
182
  throw new Error('Should have been right');
192
183
  })(inputTypes)();
193
184
  const expectedInputFile = `export interface CreatePostInput {
@@ -198,8 +189,8 @@ describe('GenerateInputSchema', () => {
198
189
  }
199
190
  `;
200
191
  expect(generatedInputFile).toEqual(expectedInputFile);
201
- }));
202
- it('it should process an endpoint with query string parameter array and generate input.ts file contents', () => __awaiter(void 0, void 0, void 0, function* () {
192
+ });
193
+ it('it should process an endpoint with query string parameter array and generate input.ts file contents', async () => {
203
194
  const endpoint = {
204
195
  operationId: 'getPost',
205
196
  description: '',
@@ -245,7 +236,7 @@ describe('GenerateInputSchema', () => {
245
236
  throw new Error('Should have been right');
246
237
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
247
238
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
248
- const generatedInputFile = yield TE.getOrElse((error) => {
239
+ const generatedInputFile = await TE.getOrElse((error) => {
249
240
  throw new Error('Should have been right');
250
241
  })(inputTypes)();
251
242
  const expectedInputFile = `export interface GetPostInput {
@@ -256,5 +247,5 @@ describe('GenerateInputSchema', () => {
256
247
  }
257
248
  `;
258
249
  expect(generatedInputFile).toEqual(expectedInputFile);
259
- }));
250
+ });
260
251
  });
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  const E = __importStar(require("fp-ts/Either"));
36
27
  const TE = __importStar(require("fp-ts/TaskEither"));
@@ -38,7 +29,7 @@ const O = __importStar(require("fp-ts/Option"));
38
29
  const GenerateInputSchema_1 = require("./GenerateInputSchema");
39
30
  const GenerateInputTypes_1 = require("./GenerateInputTypes");
40
31
  describe('GenerateInputType', () => {
41
- it('it should generate a schema from an endpoint with body parameters', () => __awaiter(void 0, void 0, void 0, function* () {
32
+ it('it should generate a schema from an endpoint with body parameters', async () => {
42
33
  const endpoint = {
43
34
  operationId: 'createPost',
44
35
  description: 'Create a new post',
@@ -178,8 +169,8 @@ describe('GenerateInputType', () => {
178
169
  in: O.none,
179
170
  };
180
171
  expect(inputSchema).toEqual(expectedInputSchema);
181
- }));
182
- it('it should process an endpoint with path, query string and body parameters and generate input.ts file contents', () => __awaiter(void 0, void 0, void 0, function* () {
172
+ });
173
+ it('it should process an endpoint with path, query string and body parameters and generate input.ts file contents', async () => {
183
174
  const endpoint = {
184
175
  operationId: 'getPost',
185
176
  description: '',
@@ -285,7 +276,7 @@ describe('GenerateInputType', () => {
285
276
  throw new Error('Should have been right');
286
277
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
287
278
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
288
- const generatedInputFile = yield TE.getOrElse((error) => {
279
+ const generatedInputFile = await TE.getOrElse((error) => {
289
280
  throw new Error('Should have been right');
290
281
  })(inputTypes)();
291
282
  const expectedInputFile = `export interface GetPostInput {
@@ -303,8 +294,8 @@ describe('GenerateInputType', () => {
303
294
  }
304
295
  `;
305
296
  expect(generatedInputFile).toEqual(expectedInputFile);
306
- }));
307
- it('it should process an endpoint with no parameters and generate empty input.ts file contents', () => __awaiter(void 0, void 0, void 0, function* () {
297
+ });
298
+ it('it should process an endpoint with no parameters and generate empty input.ts file contents', async () => {
308
299
  const endpoint = {
309
300
  operationId: 'getPosts',
310
301
  description: '',
@@ -317,14 +308,14 @@ describe('GenerateInputType', () => {
317
308
  throw new Error('Should have been right');
318
309
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
319
310
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
320
- const generatedInputFile = yield TE.getOrElse((error) => {
311
+ const generatedInputFile = await TE.getOrElse((error) => {
321
312
  throw new Error('Should have been right');
322
313
  })(inputTypes)();
323
314
  const expectedInputFile = `export interface GetPostsInput {}
324
315
  `;
325
316
  expect(generatedInputFile).toEqual(expectedInputFile);
326
- }));
327
- it('it should process an endpoint with a body schema with no parameters and additionalProperties: true and generate k: string: unknown input.ts file contents', () => __awaiter(void 0, void 0, void 0, function* () {
317
+ });
318
+ it('it should process an endpoint with a body schema with no parameters and additionalProperties: true and generate k: string: unknown input.ts file contents', async () => {
328
319
  const endpoint = {
329
320
  operationId: 'getPosts',
330
321
  description: '',
@@ -354,7 +345,7 @@ describe('GenerateInputType', () => {
354
345
  throw new Error('Should have been right');
355
346
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
356
347
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
357
- const generatedInputFile = yield TE.getOrElse((error) => {
348
+ const generatedInputFile = await TE.getOrElse((error) => {
358
349
  throw new Error('Should have been right');
359
350
  })(inputTypes)();
360
351
  const expectedInputFile = `export interface GetPostsInput {
@@ -362,8 +353,8 @@ describe('GenerateInputType', () => {
362
353
  }
363
354
  `;
364
355
  expect(generatedInputFile).toEqual(expectedInputFile);
365
- }));
366
- it('it should throw an exception when finding an unsupported media type', () => __awaiter(void 0, void 0, void 0, function* () {
356
+ });
357
+ it('it should throw an exception when finding an unsupported media type', async () => {
367
358
  const endpoint = {
368
359
  operationId: 'createPost',
369
360
  description: '',
@@ -443,5 +434,5 @@ describe('GenerateInputType', () => {
443
434
  throw new Error('Should have been left');
444
435
  }
445
436
  expect(inputSchema.left.message).toEqual('Unsupported media type: unsupported-media-type');
446
- }));
437
+ });
447
438
  });
@@ -22,23 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  const TE = __importStar(require("fp-ts/TaskEither"));
36
27
  const E = __importStar(require("fp-ts/Either"));
37
28
  const O = __importStar(require("fp-ts/Option"));
38
29
  const GenerateOutput_1 = require("./GenerateOutput");
39
- const generateOutputFileContents = (responses) => __awaiter(void 0, void 0, void 0, function* () {
30
+ const generateOutputFileContents = async (responses) => {
40
31
  const operationNameCamelCase = 'CreatePost';
41
- const generatedOutputSchema = yield (0, GenerateOutput_1.generateOutputSchema)(responses)();
32
+ const generatedOutputSchema = await (0, GenerateOutput_1.generateOutputSchema)(responses)();
42
33
  if (E.isLeft(generatedOutputSchema)) {
43
34
  throw new Error('Should have been right');
44
35
  }
@@ -46,9 +37,9 @@ const generateOutputFileContents = (responses) => __awaiter(void 0, void 0, void
46
37
  return TE.getOrElse((error) => {
47
38
  throw new Error('Should have been right');
48
39
  })(generatedOutputTypes)();
49
- });
40
+ };
50
41
  describe('Generate output: ', () => {
51
- it('it should generate output.ts file contents for a response code 200 content json', () => __awaiter(void 0, void 0, void 0, function* () {
42
+ it('it should generate output.ts file contents for a response code 200 content json', async () => {
52
43
  const responses = O.some({
53
44
  '200': {
54
45
  description: 'A post was created',
@@ -119,7 +110,7 @@ describe('Generate output: ', () => {
119
110
  }),
120
111
  },
121
112
  });
122
- const generatedOutputFileContents = yield generateOutputFileContents(responses);
113
+ const generatedOutputFileContents = await generateOutputFileContents(responses);
123
114
  const expectedOutputFileContents = `export interface CreatePostOutput {
124
115
  id: number;
125
116
  userId: number;
@@ -128,8 +119,8 @@ describe('Generate output: ', () => {
128
119
  }
129
120
  `;
130
121
  expect(generatedOutputFileContents).toEqual(expectedOutputFileContents);
131
- }));
132
- it('it should generate output.ts file contents for a response code 201 content json', () => __awaiter(void 0, void 0, void 0, function* () {
122
+ });
123
+ it('it should generate output.ts file contents for a response code 201 content json', async () => {
133
124
  const responses = O.some({
134
125
  '201': {
135
126
  description: 'A post was created',
@@ -200,7 +191,7 @@ describe('Generate output: ', () => {
200
191
  }),
201
192
  },
202
193
  });
203
- const generatedOutputFileContents = yield generateOutputFileContents(responses);
194
+ const generatedOutputFileContents = await generateOutputFileContents(responses);
204
195
  const expectedOutputFileContents = `export interface CreatePostOutput {
205
196
  id: number;
206
197
  userId: number;
@@ -209,5 +200,5 @@ describe('Generate output: ', () => {
209
200
  }
210
201
  `;
211
202
  expect(generatedOutputFileContents).toEqual(expectedOutputFileContents);
212
- }));
203
+ });
213
204
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/tray-openapi",
3
- "version": "3.8.1-beta",
3
+ "version": "3.9.1",
4
4
  "description": "Creating CDK Projects from OpenAPI 3.0 Schemas",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"