@trayio/tray-openapi 4.16.1 → 4.16.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.
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiSchemaImporter.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaImporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASvC,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAGlE,OAAO,EAEN,sBAAsB,EAMtB,MAAM,0BAA0B,CAAC;AAalC,qBAAa,qBAAqB;IACrB,OAAO,CAAC,SAAS;IAAa,OAAO,CAAC,WAAW;gBAAzC,SAAS,EAAE,SAAS,EAAU,WAAW,EAAE,WAAW;IAE1E,cAAc,CACb,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,GACnB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,sBAAsB,CAAC;IAoD/C,OAAO,CAAC,yBAAyB;IAyDjC,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,cAAc;IAoCtB,OAAO,CAAC,oCAAoC;IA4F5C,OAAO,CAAC,0BAA0B;IAwBlC,OAAO,CAAC,0BAA0B;CAclC"}
1
+ {"version":3,"file":"OpenApiSchemaImporter.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaImporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASvC,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAGlE,OAAO,EAEN,sBAAsB,EAMtB,MAAM,0BAA0B,CAAC;AAalC,qBAAa,qBAAqB;IACrB,OAAO,CAAC,SAAS;IAAa,OAAO,CAAC,WAAW;gBAAzC,SAAS,EAAE,SAAS,EAAU,WAAW,EAAE,WAAW;IAE1E,cAAc,CACb,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,GACnB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,sBAAsB,CAAC;IAoD/C,OAAO,CAAC,yBAAyB;IAyDjC,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,cAAc;IAoCtB,OAAO,CAAC,oCAAoC;IAwF5C,OAAO,CAAC,0BAA0B;IAwBlC,OAAO,CAAC,0BAA0B;CAclC"}
@@ -128,7 +128,7 @@ class OpenApiSchemaImporter {
128
128
  })), TE.chain((handlerInput) => writeFile(handlerInput, 'handler.test.ts')), TE.mapLeft((error) => handleFileCreationError(error, 'handler.test.ts'))),
129
129
  generateOutputType: (0, function_1.pipe)((0, GenerateOutput_1.generateOutputTypes)(operationName, output), TE.chain((outputType) => writeFile(outputType, 'output.ts')), TE.mapLeft((error) => handleFileCreationError(error, 'output.ts'))),
130
130
  generateInputType: (0, function_1.pipe)((0, GenerateInputTypes_1.generateInputTypes)(operationName, input), TE.chain((inputType) => writeFile(inputType, 'input.ts')), TE.mapLeft((error) => handleFileCreationError(error, 'input.ts'))),
131
- operationJson: (0, function_1.pipe)((0, GenerateOperationJson_1.generateOperationJson)((0, lodash_1.snakeCase)(operationName), (0, lodash_1.kebabCase)(operationName), path), TE.chain((operationJson) => writeFile(operationJson, 'operation.json')), TE.mapLeft((error) => handleFileCreationError(error, 'operation.json'))),
131
+ operationJson: (0, function_1.pipe)((0, GenerateOperationJson_1.generateOperationJson)(operationName, path), TE.chain((operationJson) => writeFile(operationJson, 'operation.json')), TE.mapLeft((error) => handleFileCreationError(error, 'operation.json'))),
132
132
  };
133
133
  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));
134
134
  }
@@ -1,4 +1,4 @@
1
1
  import * as TE from 'fp-ts/TaskEither';
2
2
  import { Path } from '../OpenApiTypeDescriptors';
3
- export declare const generateOperationJson: (operationNameSnakeCase: string, operationNameKebabCase: string, path: Path) => TE.TaskEither<Error, string>;
3
+ export declare const generateOperationJson: (operationName: string, path: Path) => TE.TaskEither<Error, string>;
4
4
  //# 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,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEjD,eAAO,MAAM,qBAAqB,2BACT,MAAM,0BACN,MAAM,QACxB,IAAI,KACR,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAsB7B,CAAC"}
1
+ {"version":3,"file":"GenerateOperationJson.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateOperationJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEjD,eAAO,MAAM,qBAAqB,kBAClB,MAAM,QACf,IAAI,KACR,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAyB7B,CAAC"}
@@ -27,11 +27,14 @@ exports.generateOperationJson = void 0;
27
27
  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
- const generateOperationJson = (operationNameSnakeCase, operationNameKebabCase, path) => {
30
+ const lodash_1 = require("lodash");
31
+ const generateOperationJson = (operationName, path) => {
31
32
  const operationDescription = O.getOrElse(() => O.getOrElse(() => '')(path.summary))(path.description);
33
+ const operationNameSnakeCase = (0, lodash_1.startCase)((0, lodash_1.snakeCase)(operationName));
34
+ const operationNameTitleCase = (0, lodash_1.startCase)((0, lodash_1.camelCase)(operationName));
32
35
  return (0, function_1.pipe)(operationDescription, TE.fromPredicate((description) => description.length > 0, () => new Error('Operation description is empty')), TE.map((description) => ({
33
36
  name: operationNameSnakeCase,
34
- title: operationNameKebabCase,
37
+ title: operationNameTitleCase,
35
38
  description,
36
39
  })), TE.map((operationJson) => JSON.stringify(operationJson, null, 2)), TE.mapLeft((error) => new Error(`Failed to generate operation.json for operation: ${error}`)));
37
40
  };
@@ -28,8 +28,7 @@ const O = __importStar(require("fp-ts/Option"));
28
28
  const GenerateOperationJson_1 = require("./GenerateOperationJson");
29
29
  describe('generateOperationJson', () => {
30
30
  it('should generate correct data for operation.json', async () => {
31
- const operationNameSnakeCase = 'get_photo';
32
- const operationNameKebabCase = 'get-photo';
31
+ const operationName = 'getPhoto';
33
32
  const path = {
34
33
  operationId: 'get_photo',
35
34
  description: O.some('Get a photo'),
@@ -39,19 +38,18 @@ describe('generateOperationJson', () => {
39
38
  requestBody: O.none,
40
39
  responses: O.none,
41
40
  };
42
- const result = await (0, GenerateOperationJson_1.generateOperationJson)(operationNameSnakeCase, operationNameKebabCase, path)();
41
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(operationName, path)();
43
42
  if (E.isLeft(result)) {
44
43
  throw new Error('expected result to be right');
45
44
  }
46
45
  expect(result.right).toEqual(JSON.stringify({
47
46
  name: 'get_photo',
48
- title: 'get-photo',
47
+ title: 'Get Photo',
49
48
  description: 'Get a photo',
50
49
  }, null, 2));
51
50
  });
52
51
  it('should generate operation.json with summary if description is not present', async () => {
53
- const operationNameSnakeCase = 'get_photo';
54
- const operationNameKebabCase = 'get-photo';
52
+ const operationName = 'getPhoto';
55
53
  const path = {
56
54
  operationId: 'get_photo',
57
55
  description: O.none,
@@ -61,13 +59,13 @@ describe('generateOperationJson', () => {
61
59
  requestBody: O.none,
62
60
  responses: O.none,
63
61
  };
64
- const result = await (0, GenerateOperationJson_1.generateOperationJson)(operationNameSnakeCase, operationNameKebabCase, path)();
62
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(operationName, path)();
65
63
  if (E.isLeft(result)) {
66
64
  throw new Error('expected result to be right');
67
65
  }
68
66
  expect(result.right).toEqual(JSON.stringify({
69
67
  name: 'get_photo',
70
- title: 'get-photo',
68
+ title: 'Get Photo',
71
69
  description: 'Get a photo',
72
70
  }, null, 2));
73
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/tray-openapi",
3
- "version": "4.16.1",
3
+ "version": "4.16.2",
4
4
  "description": "Creating CDK Projects from OpenAPI 3.0 Schemas",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"