-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi-ts.config.ts
More file actions
38 lines (36 loc) · 956 Bytes
/
openapi-ts.config.ts
File metadata and controls
38 lines (36 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { defineConfig, OperationPath } from '@hey-api/openapi-ts';
/**
* Converts a kebab-case path segment to camelCase.
* e.g., "angel-numbers" -> "angelNumbers", "vedic-astrology" -> "vedicAstrology"
*/
function kebabToCamel(s: string): string {
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
}
export default defineConfig({
input: './specs/openapi.json',
output: {
path: 'src',
clean: false,
},
plugins: [
'@hey-api/typescript',
{
name: '@hey-api/sdk',
operations: {
strategy: 'single',
containerName: 'Roxy',
nesting(operation) {
const path = operation.path as string;
const segment = path.split('/').filter(Boolean)[0];
if (!segment) {
return OperationPath.id()(operation);
}
const namespace = kebabToCamel(segment);
const operationId = operation.operationId ?? operation.id;
return [namespace, operationId];
},
},
},
'@hey-api/client-fetch',
],
});