@trayio/tray-openapi 4.0.1 → 4.1.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.
- package/dist/OpenApiSchemaImporter.js +1 -1
- package/dist/OpenApiTypeDescriptors.d.ts +2 -1
- package/dist/OpenApiTypeDescriptors.d.ts.map +1 -1
- package/dist/OpenApiTypeDescriptors.js +2 -1
- package/dist/file-generators/GenerateOperationJson.d.ts +2 -1
- package/dist/file-generators/GenerateOperationJson.d.ts.map +1 -1
- package/dist/file-generators/GenerateOperationJson.js +6 -7
- package/dist/file-generators/GenerateOperationJson.test.js +48 -5
- package/dist/file-generators/types/GenerateInputSchema.test.js +6 -3
- package/dist/file-generators/types/GenerateInputType.test.js +10 -5
- package/package.json +1 -1
|
@@ -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
|
|
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[]>;
|
|
@@ -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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
|
});
|
|
89
89
|
exports.openApiSpecPathTypeDescriptor = t.type({
|
|
90
|
-
description: t.string,
|
|
90
|
+
description: (0, io_ts_types_1.optionFromNullable)(t.string),
|
|
91
|
+
summary: (0, io_ts_types_1.optionFromNullable)(t.string),
|
|
91
92
|
tags: (0, io_ts_types_1.optionFromNullable)(t.array(t.string)),
|
|
92
93
|
operationId: t.string,
|
|
93
94
|
parameters: (0, io_ts_types_1.optionFromNullable)(t.array(exports.parameterSchemaTypeDescriptor)),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as TE from 'fp-ts/TaskEither';
|
|
2
2
|
import { FileStorage } from '@trayio/commons/file/File';
|
|
3
|
-
|
|
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;
|
|
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,
|
|
32
|
-
const
|
|
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
|
|
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
|
|
38
|
-
|
|
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
|
|
55
|
-
|
|
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
|
|
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
|
{
|
|
@@ -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({
|