fork of hey-api/openapi-ts because I need some additional things
1import type { UserConfig } from '@hey-api/openapi-python';
2
3export type PluginConfig = NonNullable<NonNullable<UserConfig['plugins']>[number]>;
4
5export const presets = {
6 sdk: () => [
7 /** SDK */
8 {
9 name: '@hey-api/python-sdk',
10 operations: {
11 containerName: 'OpenCode',
12 strategy: 'single',
13 },
14 paramsStructure: 'flat',
15 },
16 ],
17 validated: () => [
18 /** SDK + Pydantic validation */
19 {
20 name: '@hey-api/python-sdk',
21 paramsStructure: 'flat',
22 },
23 'pydantic',
24 ],
25} as const satisfies Record<string, () => ReadonlyArray<PluginConfig>>;
26
27export type PresetKey = keyof typeof presets;
28
29export function getPreset(key: PresetKey = (process.env.PRESET as PresetKey) || 'sdk') {
30 const preset = presets[key];
31 if (!preset) {
32 throw new Error(`Unknown preset: ${key}. Available: ${Object.keys(presets).join(', ')}`);
33 }
34 return preset();
35}