vls-openapi-generator 1.4.0 → 1.5.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/generate-openapi.js +2 -1
- package/dist/lambda-type.d.ts +9 -0
- package/dist/openapi-type.d.ts +20 -22
- package/package.json +1 -1
- package/src/generate-openapi.ts +6 -2
- package/src/lambda-type.ts +10 -0
- package/src/openapi-type.ts +33 -30
package/dist/generate-openapi.js
CHANGED
|
@@ -61,6 +61,7 @@ const generateOpenAPI = async () => {
|
|
|
61
61
|
for (const handler of handlerFiles) {
|
|
62
62
|
const fileName = path.parse(handler).name;
|
|
63
63
|
const { bodySchema, queryParametersSchema, eventResponseParametersSchema, eventResponseModulesSchema, OPENAPI_CONFIG: openAPIConfig } = (await Promise.resolve(`${path.join(SCHEMAS_DIR, fileName + '.js')}`).then(s => __importStar(require(s))).catch(() => ({})));
|
|
64
|
+
const { LAMBDA_CONFIG } = (await Promise.resolve(`${path.join(HANDLERS_DIR, `${fileName}.js`)}`).then(s => __importStar(require(s))));
|
|
64
65
|
const bodyComponent = (0, zod_openapi_1.generateSchema)(bodySchema ?? zod_1.z.never(), undefined, '3.0');
|
|
65
66
|
const queryParametersComponent = (0, zod_openapi_1.generateSchema)(queryParametersSchema ?? zod_1.z.never(), undefined, '3.0');
|
|
66
67
|
const eventResponseComponent = (0, zod_openapi_1.generateSchema)(zod_1.z.object({
|
|
@@ -91,7 +92,7 @@ const generateOpenAPI = async () => {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
existingOpenAPIFile.paths['/' + fileName] = {
|
|
94
|
-
post: {
|
|
95
|
+
[LAMBDA_CONFIG?.method?.toLowerCase() ?? 'post']: {
|
|
95
96
|
tags: openAPIConfig.tags,
|
|
96
97
|
parameters: queryParametersSchema ? queryParameters : undefined,
|
|
97
98
|
requestBody: bodySchema
|
package/dist/lambda-type.d.ts
CHANGED
package/dist/openapi-type.d.ts
CHANGED
|
@@ -12,32 +12,30 @@ export type OpenAPI = {
|
|
|
12
12
|
}, {
|
|
13
13
|
url: string;
|
|
14
14
|
}];
|
|
15
|
-
paths: Record<string, {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
paths: Record<string, Partial<Record<'get' | 'post', {
|
|
16
|
+
parameters: {
|
|
17
|
+
name: string;
|
|
18
|
+
in: 'query';
|
|
19
|
+
schema: ReturnType<typeof generateSchema>;
|
|
20
|
+
}[] | undefined;
|
|
21
|
+
requestBody: {
|
|
22
|
+
required: true;
|
|
23
|
+
content: {
|
|
24
|
+
'application/json': {
|
|
25
|
+
schema: ReturnType<typeof generateSchema>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
} | undefined;
|
|
29
|
+
responses: {
|
|
30
|
+
200: {
|
|
31
|
+
description: string;
|
|
24
32
|
content: {
|
|
25
33
|
'application/json': {
|
|
26
34
|
schema: ReturnType<typeof generateSchema>;
|
|
27
35
|
};
|
|
28
|
-
};
|
|
29
|
-
} | undefined;
|
|
30
|
-
responses: {
|
|
31
|
-
200: {
|
|
32
|
-
description: string;
|
|
33
|
-
content: {
|
|
34
|
-
'application/json': {
|
|
35
|
-
schema: ReturnType<typeof generateSchema>;
|
|
36
|
-
};
|
|
37
|
-
} | undefined;
|
|
38
|
-
};
|
|
36
|
+
} | undefined;
|
|
39
37
|
};
|
|
40
|
-
tags: string[];
|
|
41
38
|
};
|
|
42
|
-
|
|
39
|
+
tags: string[];
|
|
40
|
+
}>>>;
|
|
43
41
|
};
|
package/package.json
CHANGED
package/src/generate-openapi.ts
CHANGED
|
@@ -5,7 +5,7 @@ import 'module-alias/register.js';
|
|
|
5
5
|
import * as path from 'path';
|
|
6
6
|
import { promisify } from 'util';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import { OpenAPIConfig } from './lambda-type';
|
|
8
|
+
import { LambdaConfig, OpenAPIConfig } from './lambda-type';
|
|
9
9
|
import { OpenAPI } from './openapi-type';
|
|
10
10
|
|
|
11
11
|
const OPENAPI_FILE = path.join(process.cwd(), 'openapi.json');
|
|
@@ -49,6 +49,10 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
49
49
|
OPENAPI_CONFIG: OpenAPIConfig;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
const { LAMBDA_CONFIG } = (await import(path.join(HANDLERS_DIR, `${fileName}.js`))) as {
|
|
53
|
+
LAMBDA_CONFIG?: LambdaConfig;
|
|
54
|
+
};
|
|
55
|
+
|
|
52
56
|
const bodyComponent = generateSchema(bodySchema ?? z.never(), undefined, '3.0');
|
|
53
57
|
const queryParametersComponent = generateSchema(queryParametersSchema ?? z.never(), undefined, '3.0');
|
|
54
58
|
const eventResponseComponent = generateSchema(
|
|
@@ -88,7 +92,7 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
existingOpenAPIFile.paths['/' + fileName] = {
|
|
91
|
-
post: {
|
|
95
|
+
[LAMBDA_CONFIG?.method?.toLowerCase() ?? 'post']: {
|
|
92
96
|
tags: openAPIConfig.tags,
|
|
93
97
|
parameters: queryParametersSchema ? queryParameters : undefined,
|
|
94
98
|
requestBody: bodySchema
|
package/src/lambda-type.ts
CHANGED
package/src/openapi-type.ts
CHANGED
|
@@ -6,39 +6,42 @@ export type OpenAPI = {
|
|
|
6
6
|
servers: [{ url: string }, { url: string }, { url: string }];
|
|
7
7
|
paths: Record<
|
|
8
8
|
string,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
| undefined;
|
|
28
|
-
responses: {
|
|
29
|
-
200: {
|
|
30
|
-
description: string;
|
|
31
|
-
content:
|
|
32
|
-
| {
|
|
9
|
+
Partial<
|
|
10
|
+
Record<
|
|
11
|
+
'get' | 'post',
|
|
12
|
+
{
|
|
13
|
+
parameters:
|
|
14
|
+
| {
|
|
15
|
+
name: string;
|
|
16
|
+
in: 'query';
|
|
17
|
+
schema: ReturnType<typeof generateSchema>;
|
|
18
|
+
}[]
|
|
19
|
+
| undefined;
|
|
20
|
+
requestBody:
|
|
21
|
+
| {
|
|
22
|
+
required: true;
|
|
23
|
+
content: {
|
|
33
24
|
'application/json': {
|
|
34
25
|
schema: ReturnType<typeof generateSchema>;
|
|
35
26
|
};
|
|
36
|
-
}
|
|
37
|
-
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
| undefined;
|
|
30
|
+
responses: {
|
|
31
|
+
200: {
|
|
32
|
+
description: string;
|
|
33
|
+
content:
|
|
34
|
+
| {
|
|
35
|
+
'application/json': {
|
|
36
|
+
schema: ReturnType<typeof generateSchema>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
| undefined;
|
|
40
|
+
};
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
tags: string[];
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
>
|
|
43
46
|
>;
|
|
44
47
|
};
|