@trayio/tray-openapi 4.0.0 → 4.0.2

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.
@@ -127,7 +127,7 @@ class OpenApiSchemaImporter {
127
127
  })), TE.chain((handlerInput) => writeFile(handlerInput, 'handler.test.ts'))),
128
128
  generateOutputType: (0, function_1.pipe)((0, GenerateOutput_1.generateOutputTypes)(operationName, output), TE.chain((outputType) => writeFile(outputType, 'output.ts'))),
129
129
  generateInputType: (0, function_1.pipe)((0, GenerateInputTypes_1.generateInputTypes)(operationName, input), TE.chain((inputType) => writeFile(inputType, 'input.ts'))),
130
- operationJson: (0, GenerateOperationJson_1.generateOperationJson)(this.fileStorage, operationPath, operationName, (0, lodash_1.kebabCase)(operationName), path.description),
130
+ operationJson: (0, GenerateOperationJson_1.generateOperationJson)(this.fileStorage, operationPath, operationName, (0, lodash_1.kebabCase)(operationName), path),
131
131
  };
132
132
  return (0, function_1.pipe)((0, Apply_1.sequenceS)(TE.ApplicativePar)(operationFileGenerationTasks), TE.mapLeft((error) => new Error(`Failed to generate files for operation: ${operationName}: ${error}`)), TE.map(() => undefined));
133
133
  }
@@ -37,7 +37,8 @@ export type BuildConnectorResponse = {
37
37
  errors: OperationError[];
38
38
  };
39
39
  export type Path = {
40
- description: string;
40
+ description: O.Option<string>;
41
+ summary: O.Option<string>;
41
42
  tags: O.Option<string[]>;
42
43
  operationId: string;
43
44
  parameters: O.Option<Parameter[]>;
@@ -81,9 +82,10 @@ export type OpenAPISchema = {
81
82
  };
82
83
  export type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
83
84
  export interface ArraySchemaObject extends BaseSchemaObject {
84
- type: 'array';
85
+ type: O.Option<'array'>;
85
86
  items: SchemaObject;
86
87
  }
88
+ export type SchemaObjectType = 'array' | NonArraySchemaObjectType;
87
89
  export type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
88
90
  export interface NonArraySchemaObject extends BaseSchemaObject {
89
91
  type: O.Option<NonArraySchemaObjectType>;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiTypeDescriptors.d.ts","sourceRoot":"","sources":["../src/OpenApiTypeDescriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,MAAM,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC5C,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC9C,GAAG,EAAE,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9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IAAI,CAAC,YAAY,EAAE,OAAO,CAMnE,CAAC;AAEH,eAAO,MAAM,qBAAqB,wDAEjC,CAAC;AAuBF,eAAO,MAAM,6BAA6B,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAQpE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAQ9D,CAAC;AAUH,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAWpE,CAAC"}
@@ -48,7 +48,10 @@ exports.baseSchemaObjectSchemaTypeDescriptor = t.recursion('baseSchema', () => t
48
48
  }));
49
49
  const arraySchemaObjectSchemaTypeDescriptor = t.recursion('ArraySchema', () => t.intersection([
50
50
  exports.baseSchemaObjectSchemaTypeDescriptor,
51
- t.type({ type: t.literal('array'), items: exports.schemaObjectTypeDescriptor }),
51
+ t.type({
52
+ type: (0, io_ts_types_1.optionFromNullable)(t.literal('array')),
53
+ items: exports.schemaObjectTypeDescriptor,
54
+ }),
52
55
  ]));
53
56
  const nonArraySchemaObjectSchemaTypeDescriptor = t.recursion('nonArraySchema', () => t.intersection([
54
57
  exports.baseSchemaObjectSchemaTypeDescriptor,
@@ -84,7 +87,8 @@ exports.parameterSchemaTypeDescriptor = t.type({
84
87
  schema: exports.schemaObjectTypeDescriptor,
85
88
  });
86
89
  exports.openApiSpecPathTypeDescriptor = t.type({
87
- description: t.string,
90
+ description: (0, io_ts_types_1.optionFromNullable)(t.string),
91
+ summary: (0, io_ts_types_1.optionFromNullable)(t.string),
88
92
  tags: (0, io_ts_types_1.optionFromNullable)(t.array(t.string)),
89
93
  operationId: t.string,
90
94
  parameters: (0, io_ts_types_1.optionFromNullable)(t.array(exports.parameterSchemaTypeDescriptor)),
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateHandler.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAEN,YAAY,EACZ,MAAM,2BAA2B,CAAC;AAEnC,KAAK,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;CACpB,CAAC;AAsHF,eAAO,MAAM,eAAe,wHAQzB,oBAAoB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAoB9C,CAAC"}
1
+ {"version":3,"file":"GenerateHandler.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAEN,YAAY,EAEZ,MAAM,2BAA2B,CAAC;AAEnC,KAAK,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;CACpB,CAAC;AAiHF,eAAO,MAAM,eAAe,wHAQzB,oBAAoB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAoB9C,CAAC"}
@@ -59,10 +59,6 @@ const constructInputs = (properties) => {
59
59
  const handlerInput = inputsArray.map(([name, input], index) => {
60
60
  const prefix = index === 0 ? 'request.' : '';
61
61
  let inputMapping = '';
62
- if (input.type === 'array') {
63
- // TODO: improve error message and ideally handle this more gracefully, do we expect array types at the root level?
64
- throw new Error('Array type not yet supported');
65
- }
66
62
  return O.fold(() => '', (inputIn) => {
67
63
  switch (inputIn) {
68
64
  case 'body':
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateHandlerTest.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandlerTest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG;IACtC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;CACrB,CAAC;AAiDF,eAAO,MAAM,mBAAmB,+CAI7B,wBAAwB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAqClD,CAAC"}
1
+ {"version":3,"file":"GenerateHandlerTest.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandlerTest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAqB,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE5E,MAAM,MAAM,wBAAwB,GAAG;IACtC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;CACrB,CAAC;AA+CF,eAAO,MAAM,mBAAmB,+CAI7B,wBAAwB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAqClD,CAAC"}
@@ -26,29 +26,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.generateHandlerTest = void 0;
27
27
  const E = __importStar(require("fp-ts/Either"));
28
28
  const O = __importStar(require("fp-ts/Option"));
29
- const getDefaultValue = (prop) => {
30
- if (prop.type === 'array') {
31
- return prop.items ? `[${getDefaultValue(prop.items)}]` : '[]';
29
+ const getDefaultValue = (prop) => O.fold(() => `'test_value'`, (type) => {
30
+ switch (type) {
31
+ case 'string':
32
+ return `'test'`;
33
+ case 'number':
34
+ case 'integer':
35
+ return 2;
36
+ case 'boolean':
37
+ return 'true';
38
+ case 'array':
39
+ const arrayProp = prop;
40
+ return arrayProp.items
41
+ ? `[${getDefaultValue(arrayProp.items)}]`
42
+ : '[]';
43
+ case 'object':
44
+ return O.fold(() => `{}`, (properties) => handleInput(properties))(prop.properties);
45
+ default:
46
+ return `'test_value'`;
32
47
  }
33
- return O.fold(() => `'test_value'`, (type) => {
34
- switch (type) {
35
- case 'string':
36
- return `'test'`;
37
- case 'number':
38
- case 'integer':
39
- return 2;
40
- case 'boolean':
41
- return 'true';
42
- // case 'array':
43
- // return prop.items ? `[${getDefaultValue(prop.items)}]` : '[]';
44
- case 'object':
45
- return O.fold(() => `{}`, (properties) => handleInput(properties))(prop.properties);
46
- // return prop.properties ? handleInput(prop.properties) : '{}';
47
- default:
48
- return `'test_value'`;
49
- }
50
- })(prop.type);
51
- };
48
+ })(prop.type);
52
49
  // TODO: make handleInput and handleOutput accept an option and do the fold inside, will make the code cleaner in the template and switch case
53
50
  const handleInput = (inputs) => {
54
51
  const populatedTestInputs = Object.entries(inputs).map(([key, prop]) => `${key}: ${getDefaultValue(prop)}`);
@@ -337,7 +337,7 @@ describe('GenerateHandlerTest', () => {
337
337
  properties: O.some({
338
338
  ids: {
339
339
  title: O.none,
340
- type: 'array',
340
+ type: O.some('array'),
341
341
  items: {
342
342
  title: O.none,
343
343
  type: O.some('integer'),
@@ -374,7 +374,7 @@ describe('GenerateHandlerTest', () => {
374
374
  properties: O.some({
375
375
  parents: {
376
376
  title: O.none,
377
- type: 'array',
377
+ type: O.some('array'),
378
378
  items: {
379
379
  title: O.none,
380
380
  type: O.some('string'),
@@ -472,7 +472,7 @@ describe('GenerateHandlerTest', () => {
472
472
  },
473
473
  valueList: {
474
474
  title: O.none,
475
- type: 'array',
475
+ type: O.some('array'),
476
476
  items: {
477
477
  title: O.none,
478
478
  type: O.some('string'),
@@ -563,7 +563,7 @@ describe('GenerateHandlerTest', () => {
563
563
  properties: O.some({
564
564
  parents: {
565
565
  title: O.none,
566
- type: 'array',
566
+ type: O.some('array'),
567
567
  items: {
568
568
  title: O.none,
569
569
  type: O.some('object'),
@@ -1,4 +1,5 @@
1
1
  import * as TE from 'fp-ts/TaskEither';
2
2
  import { FileStorage } from '@trayio/commons/file/File';
3
- export declare const generateOperationJson: (fileStorage: FileStorage, operationDirPath: string, operationNameSnakeCase: string, operationNameKebabCase: string, operationDescription: string) => TE.TaskEither<Error, undefined>;
3
+ import { Path } from '../OpenApiTypeDescriptors';
4
+ export declare const generateOperationJson: (fileStorage: FileStorage, operationDirPath: string, operationNameSnakeCase: string, operationNameKebabCase: string, path: Path) => TE.TaskEither<Error, undefined>;
4
5
  //# sourceMappingURL=GenerateOperationJson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateOperationJson.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateOperationJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,eAAO,MAAM,qBAAqB,gBACpB,WAAW,oBACN,MAAM,0BACA,MAAM,0BACN,MAAM,wBACR,MAAM,KAC1B,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAuBhC,CAAC"}
1
+ {"version":3,"file":"GenerateOperationJson.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateOperationJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEjD,eAAO,MAAM,qBAAqB,gBACpB,WAAW,oBACN,MAAM,0BACA,MAAM,0BACN,MAAM,QACxB,IAAI,KACR,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAgChC,CAAC"}
@@ -28,17 +28,16 @@ const TE = __importStar(require("fp-ts/TaskEither"));
28
28
  const O = __importStar(require("fp-ts/Option"));
29
29
  const function_1 = require("fp-ts/function");
30
30
  const stream_1 = require("stream");
31
- const generateOperationJson = (fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription) => {
32
- const operationJson = {
31
+ const generateOperationJson = (fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, path) => {
32
+ const operationDescription = O.getOrElse(() => O.getOrElse(() => '')(path.summary))(path.description);
33
+ return (0, function_1.pipe)(operationDescription, TE.fromPredicate((description) => description.length > 0, () => new Error('Operation description is empty')), TE.map((description) => ({
33
34
  name: operationNameSnakeCase,
34
35
  title: operationNameKebabCase,
35
- description: operationDescription,
36
- };
37
- const writeOperationJson = fileStorage.write({
36
+ description,
37
+ })), TE.chain((operationJson) => fileStorage.write({
38
38
  content: stream_1.Readable.from(JSON.stringify(operationJson)),
39
39
  key: `${operationDirPath}/operation.json`,
40
40
  metadata: { name: 'operation.json' },
41
- }, O.none);
42
- return (0, function_1.pipe)(writeOperationJson, TE.mapLeft((error) => new Error(`Failed to generate operation.json for operation: ${error}`)), TE.map(() => undefined));
41
+ }, O.none)), TE.mapLeft((error) => new Error(`Failed to generate operation.json for operation: ${error}`)), TE.map(() => undefined));
43
42
  };
44
43
  exports.generateOperationJson = generateOperationJson;
@@ -34,8 +34,16 @@ describe('generateOperationJson', () => {
34
34
  const operationDirPath = '/path/to/operation';
35
35
  const operationNameSnakeCase = 'get_photo';
36
36
  const operationNameKebabCase = 'get-photo';
37
- const operationDescription = 'Get photo operation';
38
- const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription)();
37
+ const path = {
38
+ operationId: 'get_photo',
39
+ description: O.some('Get a photo'),
40
+ summary: O.none,
41
+ tags: O.some([]),
42
+ parameters: O.none,
43
+ requestBody: O.none,
44
+ responses: O.none,
45
+ };
46
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, path)();
39
47
  if (E.isLeft(result)) {
40
48
  throw new Error('expected result to be right');
41
49
  }
@@ -51,8 +59,16 @@ describe('generateOperationJson', () => {
51
59
  const operationDirPath = '/path/to/operation';
52
60
  const operationNameSnakeCase = 'get_photo';
53
61
  const operationNameKebabCase = 'get-photo';
54
- const operationDescription = 'Get photo operation';
55
- const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, operationDescription)();
62
+ const path = {
63
+ operationId: 'get_photo',
64
+ description: O.some('Get a photo'),
65
+ summary: O.none,
66
+ tags: O.some([]),
67
+ parameters: O.none,
68
+ requestBody: O.none,
69
+ responses: O.none,
70
+ };
71
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, path)();
56
72
  if (E.isLeft(result)) {
57
73
  throw new Error('expected result to be right');
58
74
  }
@@ -63,7 +79,34 @@ describe('generateOperationJson', () => {
63
79
  expect(operationJson.content.read()).toEqual(JSON.stringify({
64
80
  name: 'get_photo',
65
81
  title: 'get-photo',
66
- description: 'Get photo operation',
82
+ description: 'Get a photo',
83
+ }));
84
+ });
85
+ it('should generate operation.json with summary if description is not present', async () => {
86
+ const operationDirPath = '/path/to/operation';
87
+ const operationNameSnakeCase = 'get_photo';
88
+ const operationNameKebabCase = 'get-photo';
89
+ const path = {
90
+ operationId: 'get_photo',
91
+ description: O.none,
92
+ summary: O.some('Get a photo'),
93
+ tags: O.some([]),
94
+ parameters: O.none,
95
+ requestBody: O.none,
96
+ responses: O.none,
97
+ };
98
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(fileStorage, operationDirPath, operationNameSnakeCase, operationNameKebabCase, path)();
99
+ if (E.isLeft(result)) {
100
+ throw new Error('expected result to be right');
101
+ }
102
+ const operationJson = fileStorage.files.get('/path/to/operation/operation.json');
103
+ if (operationJson === undefined) {
104
+ throw new Error('expected operationJson to be defined');
105
+ }
106
+ expect(operationJson.content.read()).toEqual(JSON.stringify({
107
+ name: 'get_photo',
108
+ title: 'get-photo',
109
+ description: 'Get a photo',
67
110
  }));
68
111
  });
69
112
  });
@@ -32,7 +32,8 @@ describe('GenerateInputSchema', () => {
32
32
  it('it should process an endpoint with path and query string parameters and generate input.ts file contents', async () => {
33
33
  const endpoint = {
34
34
  operationId: 'getPost',
35
- description: '',
35
+ description: O.some('Get posts'),
36
+ summary: O.none,
36
37
  tags: O.some([]),
37
38
  parameters: O.some([
38
39
  {
@@ -102,7 +103,8 @@ describe('GenerateInputSchema', () => {
102
103
  it('it should process an endpoint with body parameters and generate input.ts file contents', async () => {
103
104
  const endpoint = {
104
105
  operationId: 'createPost',
105
- description: 'Create a new post',
106
+ description: O.some('Create a new post'),
107
+ summary: O.none,
106
108
  tags: O.some([]),
107
109
  parameters: O.none,
108
110
  requestBody: O.some({
@@ -193,7 +195,8 @@ describe('GenerateInputSchema', () => {
193
195
  it('it should process an endpoint with query string parameter array and generate input.ts file contents', async () => {
194
196
  const endpoint = {
195
197
  operationId: 'getPost',
196
- description: '',
198
+ description: O.some('Get posts'),
199
+ summary: O.none,
197
200
  tags: O.some([]),
198
201
  parameters: O.some([
199
202
  {
@@ -203,7 +206,7 @@ describe('GenerateInputSchema', () => {
203
206
  description: 'tags to filter by.',
204
207
  schema: {
205
208
  title: O.none,
206
- type: 'array',
209
+ type: O.some('array'),
207
210
  format: O.none,
208
211
  items: {
209
212
  type: O.some('string'),
@@ -32,7 +32,8 @@ describe('GenerateInputType', () => {
32
32
  it('it should generate a schema from an endpoint with body parameters', async () => {
33
33
  const endpoint = {
34
34
  operationId: 'createPost',
35
- description: 'Create a new post',
35
+ description: O.some('Create a new post'),
36
+ summary: O.none,
36
37
  tags: O.some([]),
37
38
  parameters: O.none,
38
39
  requestBody: O.some({
@@ -173,7 +174,8 @@ describe('GenerateInputType', () => {
173
174
  it('it should process an endpoint with path, query string and body parameters and generate input.ts file contents', async () => {
174
175
  const endpoint = {
175
176
  operationId: 'getPost',
176
- description: '',
177
+ description: O.some('Get a post by id'),
178
+ summary: O.none,
177
179
  tags: O.some([]),
178
180
  parameters: O.some([
179
181
  {
@@ -298,7 +300,8 @@ describe('GenerateInputType', () => {
298
300
  it('it should process an endpoint with no parameters and generate empty input.ts file contents', async () => {
299
301
  const endpoint = {
300
302
  operationId: 'getPosts',
301
- description: '',
303
+ description: O.some('Get all posts'),
304
+ summary: O.none,
302
305
  tags: O.some([]),
303
306
  parameters: O.none,
304
307
  requestBody: O.none,
@@ -318,7 +321,8 @@ describe('GenerateInputType', () => {
318
321
  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 () => {
319
322
  const endpoint = {
320
323
  operationId: 'getPosts',
321
- description: '',
324
+ description: O.some('Get all posts'),
325
+ summary: O.none,
322
326
  tags: O.some([]),
323
327
  parameters: O.none,
324
328
  requestBody: O.some({
@@ -357,7 +361,8 @@ describe('GenerateInputType', () => {
357
361
  it('it should throw an exception when finding an unsupported media type', async () => {
358
362
  const endpoint = {
359
363
  operationId: 'createPost',
360
- description: '',
364
+ description: O.some('Create a new post'),
365
+ summary: O.none,
361
366
  tags: O.some([]),
362
367
  parameters: O.none,
363
368
  requestBody: O.some({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/tray-openapi",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Creating CDK Projects from OpenAPI 3.0 Schemas",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"