Skip to content

Commit d7f5e0d

Browse files
authored
Merge branch 'main' into fix/pinia-colada-query-error-type
2 parents 0c3edd8 + 3be5ff2 commit d7f5e0d

16 files changed

Lines changed: 222 additions & 45 deletions

File tree

.changeset/bitter-lines-hammer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/shared": patch
3+
---
4+
5+
**output**: context file is optional

.changeset/busy-plums-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**dsl(reserved)**: expand reserved keywords with more globals

.changeset/poor-beds-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**output(header)**: fix: support function signature in client and core files

dev/hey-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-ignore
2-
import type { CreateClientConfig } from './client/client.gen';
2+
import type { CreateClientConfig } from './.gen/typescript/client.gen';
33

44
// @ts-ignore
55
export const createClientConfig: CreateClientConfig = (config) => ({

dev/playground.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { DefinePlugin, IR } from '@hey-api/openapi-ts';
22

33
// import { createOpencode } from '@opencode-ai/sdk';
4-
import { PetStore } from './.gen/sdk.gen.ts';
4+
import { PetStore } from './.gen/typescript/sdk.gen.ts';
55

66
type MyPluginConfig = { readonly name: 'myplugin' };
77
type MyPlugin = DefinePlugin<MyPluginConfig>;

dev/python/plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { UserConfig } from '@hey-api/openapi-python';
22

3-
type PluginConfig = NonNullable<NonNullable<UserConfig['plugins']>[number]>;
3+
export type PluginConfig = NonNullable<NonNullable<UserConfig['plugins']>[number]>;
44

55
export function sdk(
66
options?: Omit<Extract<PluginConfig, { name: '@hey-api/python-sdk' }>, 'name'>,

dev/python/presets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PluginConfig } from './plugins';
12
import { pydantic, sdk } from './plugins';
23

34
export const presets = {
@@ -19,7 +20,7 @@ export const presets = {
1920
sdk(),
2021
pydantic(),
2122
],
22-
} as const;
23+
} as const satisfies Record<string, () => ReadonlyArray<PluginConfig>>;
2324

2425
export type PresetKey = keyof typeof presets;
2526

dev/typescript/plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { UserConfig } from '@hey-api/openapi-ts';
22

3-
type PluginConfig = NonNullable<NonNullable<UserConfig['plugins']>[number]>;
3+
export type PluginConfig = NonNullable<NonNullable<UserConfig['plugins']>[number]>;
44

55
export function typescript(
66
options?: Omit<Extract<PluginConfig, { name: '@hey-api/typescript' }>, 'name'>,

dev/typescript/presets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PluginConfig } from './plugins';
12
import { sdk, tanstackReactQuery, transformers, typescript, valibot, zod } from './plugins';
23

34
export const presets = {
@@ -36,7 +37,7 @@ export const presets = {
3637
valibot({ metadata: true }),
3738
zod({ metadata: true }),
3839
],
39-
} as const;
40+
} as const satisfies Record<string, () => ReadonlyArray<PluginConfig>>;
4041

4142
export type PresetKey = keyof typeof presets;
4243

packages/openapi-python/src/generate/client.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
44

55
import type { IProject, ProjectRenderMeta } from '@hey-api/codegen-core';
66
import type { DefinePlugin, OutputHeader } from '@hey-api/shared';
7-
import { ensureDirSync } from '@hey-api/shared';
7+
import { ensureDirSync, outputHeaderToPrefix } from '@hey-api/shared';
88

99
import type { Config } from '../config/types';
1010
import type { Client } from '../plugins/@hey-api/client-core/types';
@@ -53,21 +53,6 @@ function getClientBundlePaths(pluginName: string): {
5353
};
5454
}
5555

56-
/**
57-
* Converts an {@link OutputHeader} value to a string prefix for file content.
58-
* Returns an empty string when the header is null, undefined, or a function
59-
* (functions require a render context which is not available for bundled files).
60-
*/
61-
function outputHeaderToPrefix(header: OutputHeader): string {
62-
if (header == null || typeof header === 'function') return '';
63-
const lines =
64-
typeof header === 'string'
65-
? header.split(/\r?\n/)
66-
: header.flatMap((line) => line.split(/\r?\n/));
67-
const content = lines.join('\n');
68-
return content ? `${content}\n\n` : '';
69-
}
70-
7156
/**
7257
* Returns absolute path to the client folder. This is hard-coded for now.
7358
*/
@@ -186,11 +171,11 @@ export function generateClientBundle({
186171
meta: ProjectRenderMeta;
187172
outputPath: string;
188173
plugin: DefinePlugin<Client.Config & { name: string }>['Config'];
189-
project?: IProject;
174+
project: IProject;
190175
}): Map<string, string> | undefined {
191176
const renamed = new Map<string, string>();
192177
const devMode = isDevMode();
193-
const headerPrefix = outputHeaderToPrefix(header);
178+
const headerPrefix = outputHeaderToPrefix(header, project);
194179

195180
// copy Hey API clients to output
196181
const isHeyApiClientPlugin = plugin.name.startsWith('@hey-api/client-');

0 commit comments

Comments
 (0)