@trayio/tray-openapi 4.17.0 → 4.18.0

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.
@@ -30,7 +30,7 @@ const function_1 = require("fp-ts/function");
30
30
  const lodash_1 = require("lodash");
31
31
  const generateOperationJson = (operationName, path) => {
32
32
  const operationDescription = O.getOrElse(() => O.getOrElse(() => '')(path.summary))(path.description);
33
- const operationNameSnakeCase = (0, lodash_1.startCase)((0, lodash_1.snakeCase)(operationName));
33
+ const operationNameSnakeCase = (0, lodash_1.snakeCase)(operationName);
34
34
  const operationNameTitleCase = (0, lodash_1.startCase)((0, lodash_1.camelCase)(operationName));
35
35
  return (0, function_1.pipe)(operationDescription, TE.fromPredicate((description) => description.length > 0, () => new Error('Operation description is empty')), TE.map((description) => ({
36
36
  name: operationNameSnakeCase,
@@ -69,4 +69,25 @@ describe('generateOperationJson', () => {
69
69
  description: 'Get a photo',
70
70
  }, null, 2));
71
71
  });
72
+ it('should generate operation.json with a lower case name if provided with an uppercased value', async () => {
73
+ const operationName = 'getPhoto';
74
+ const path = {
75
+ operationId: 'Get Photo',
76
+ description: O.none,
77
+ summary: O.some('Get a photo'),
78
+ tags: O.some([]),
79
+ parameters: O.none,
80
+ requestBody: O.none,
81
+ responses: O.none,
82
+ };
83
+ const result = await (0, GenerateOperationJson_1.generateOperationJson)(operationName, path)();
84
+ if (E.isLeft(result)) {
85
+ throw new Error('expected result to be right');
86
+ }
87
+ expect(result.right).toEqual(JSON.stringify({
88
+ name: 'get_photo',
89
+ title: 'Get Photo',
90
+ description: 'Get a photo',
91
+ }, null, 2));
92
+ });
72
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/tray-openapi",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "Creating CDK Projects from OpenAPI 3.0 Schemas",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"