@geekmidas/cli 1.10.32 → 1.10.33
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-BQft1jm8.cjs → openapi-BQVC9vE5.cjs} +4 -3
- package/dist/{openapi-BQft1jm8.cjs.map → openapi-BQVC9vE5.cjs.map} +1 -1
- package/dist/{openapi-DE8b-vin.mjs → openapi-DY3ctapV.mjs} +4 -3
- package/dist/{openapi-DE8b-vin.mjs.map → openapi-DY3ctapV.mjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.mjs +1 -1
- package/package.json +2 -2
- package/src/generators/OpenApiTsGenerator.ts +3 -1
- package/src/generators/__tests__/OpenApiTsGenerator.responseType.spec.ts +56 -0
- package/src/init/versions.ts +2 -2
package/dist/openapi.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
require('./workspace-CGYykWfn.cjs');
|
|
3
3
|
require('./config-Cuo8vFsp.cjs');
|
|
4
|
-
const require_openapi = require('./openapi-
|
|
4
|
+
const require_openapi = require('./openapi-BQVC9vE5.cjs');
|
|
5
5
|
|
|
6
6
|
exports.OPENAPI_OUTPUT_PATH = require_openapi.OPENAPI_OUTPUT_PATH;
|
|
7
7
|
exports.generateOpenApi = require_openapi.generateOpenApi;
|
package/dist/openapi.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
import "./workspace-Bi4X7Yzy.mjs";
|
|
3
3
|
import "./config-B62g483e.mjs";
|
|
4
|
-
import { OPENAPI_OUTPUT_PATH, generateOpenApi, openapiCommand, resolveOpenApiConfig } from "./openapi-
|
|
4
|
+
import { OPENAPI_OUTPUT_PATH, generateOpenApi, openapiCommand, resolveOpenApiConfig } from "./openapi-DY3ctapV.mjs";
|
|
5
5
|
|
|
6
6
|
export { OPENAPI_OUTPUT_PATH, generateOpenApi, openapiCommand, resolveOpenApiConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/cli",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.33",
|
|
4
4
|
"description": "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"prompts": "~2.4.2",
|
|
57
57
|
"tsx": "~4.20.3",
|
|
58
58
|
"yaml": "~2.8.2",
|
|
59
|
-
"@geekmidas/constructs": "~3.0.
|
|
59
|
+
"@geekmidas/constructs": "~3.0.9",
|
|
60
60
|
"@geekmidas/envkit": "~1.0.5",
|
|
61
61
|
"@geekmidas/errors": "~1.0.0",
|
|
62
62
|
"@geekmidas/logger": "~1.0.1",
|
|
@@ -57,6 +57,7 @@ interface EndpointInfo {
|
|
|
57
57
|
description?: string;
|
|
58
58
|
tags?: string[];
|
|
59
59
|
operationId?: string;
|
|
60
|
+
responseType: string;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
interface SecuritySchemeInfo {
|
|
@@ -132,6 +133,7 @@ export class OpenApiTsGenerator {
|
|
|
132
133
|
description: ep.description,
|
|
133
134
|
tags: ep.tags,
|
|
134
135
|
operationId: ep.operationId,
|
|
136
|
+
responseType: ep.responseType ?? 'application/json',
|
|
135
137
|
};
|
|
136
138
|
});
|
|
137
139
|
}
|
|
@@ -575,7 +577,7 @@ export class OpenApiTsGenerator {
|
|
|
575
577
|
parts.push(`responses: {
|
|
576
578
|
200: {
|
|
577
579
|
content: {
|
|
578
|
-
'
|
|
580
|
+
'${info.responseType}': ${outputName};
|
|
579
581
|
};
|
|
580
582
|
};
|
|
581
583
|
}`);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { OpenApiTsGenerator } from '../OpenApiTsGenerator';
|
|
5
|
+
|
|
6
|
+
describe('OpenApiTsGenerator — responseType', () => {
|
|
7
|
+
it("emits 'application/json' in paths when responseType is default", async () => {
|
|
8
|
+
const endpoint = e
|
|
9
|
+
.get('/users')
|
|
10
|
+
.output(z.object({ id: z.string() }))
|
|
11
|
+
.handle(async () => ({ id: '1' }));
|
|
12
|
+
|
|
13
|
+
const generator = new OpenApiTsGenerator();
|
|
14
|
+
const content = await generator.generate([endpoint as any]);
|
|
15
|
+
|
|
16
|
+
// Default JSON content-type in the paths interface
|
|
17
|
+
expect(content).toContain("'application/json':");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("emits 'text/html' when the endpoint declares responseType('text/html')", async () => {
|
|
21
|
+
const endpoint = e
|
|
22
|
+
.get('/checkout-page')
|
|
23
|
+
.output(z.string())
|
|
24
|
+
.responseType('text/html')
|
|
25
|
+
.handle(async () => '<html></html>');
|
|
26
|
+
|
|
27
|
+
const generator = new OpenApiTsGenerator();
|
|
28
|
+
const content = await generator.generate([endpoint as any]);
|
|
29
|
+
|
|
30
|
+
// Paths interface should reference text/html, not application/json,
|
|
31
|
+
// for this endpoint's 200 response
|
|
32
|
+
expect(content).toContain("'text/html':");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('keeps JSON content-type for other endpoints when one uses a custom responseType', async () => {
|
|
36
|
+
const htmlEndpoint = e
|
|
37
|
+
.get('/page')
|
|
38
|
+
.output(z.string())
|
|
39
|
+
.responseType('text/html')
|
|
40
|
+
.handle(async () => '<html></html>');
|
|
41
|
+
|
|
42
|
+
const jsonEndpoint = e
|
|
43
|
+
.get('/users')
|
|
44
|
+
.output(z.object({ id: z.string() }))
|
|
45
|
+
.handle(async () => ({ id: '1' }));
|
|
46
|
+
|
|
47
|
+
const generator = new OpenApiTsGenerator();
|
|
48
|
+
const content = await generator.generate([
|
|
49
|
+
htmlEndpoint as any,
|
|
50
|
+
jsonEndpoint as any,
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
expect(content).toContain("'text/html':");
|
|
54
|
+
expect(content).toContain("'application/json':");
|
|
55
|
+
});
|
|
56
|
+
});
|
package/src/init/versions.ts
CHANGED
|
@@ -32,13 +32,13 @@ export const GEEKMIDAS_VERSIONS = {
|
|
|
32
32
|
'@geekmidas/cache': '~1.1.0',
|
|
33
33
|
'@geekmidas/client': '~4.0.4',
|
|
34
34
|
'@geekmidas/cloud': '~1.0.0',
|
|
35
|
-
'@geekmidas/constructs': '~3.0.
|
|
35
|
+
'@geekmidas/constructs': '~3.0.8',
|
|
36
36
|
'@geekmidas/db': '~1.0.1',
|
|
37
37
|
'@geekmidas/emailkit': '~1.0.0',
|
|
38
38
|
'@geekmidas/envkit': '~1.0.5',
|
|
39
39
|
'@geekmidas/errors': '~1.0.0',
|
|
40
40
|
'@geekmidas/events': '~1.1.0',
|
|
41
|
-
'@geekmidas/logger': '~1.0.
|
|
41
|
+
'@geekmidas/logger': '~1.0.1',
|
|
42
42
|
'@geekmidas/rate-limit': '~2.0.0',
|
|
43
43
|
'@geekmidas/schema': '~1.0.0',
|
|
44
44
|
'@geekmidas/services': '~1.0.1',
|