Skip to content

Commit 86a9cb0

Browse files
committed
fix: pass $ to type transformer
1 parent f10429b commit 86a9cb0

5 files changed

Lines changed: 8 additions & 5 deletions

File tree

.changeset/two-cameras-check.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@hey-api/openapi-ts": patch
33
---
44

5-
**plugin(@hey-api/transformers)**: expose plugin in transformer function context
5+
**plugin(@hey-api/transformers)**: expose `plugin` and `$` in transformer function context

dev/typescript/presets.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const presets = {
1616
name: '@hey-api/sdk',
1717
paramsStructure: 'flat',
1818
},
19-
'@hey-api/transformers',
19+
{
20+
name: '@hey-api/transformers',
21+
},
2022
{
2123
metadata: true,
2224
name: 'zod',

packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ function processSchemaType({
265265

266266
for (const transformer of plugin.config.transformers) {
267267
const t = transformer({
268+
$,
268269
config: plugin.config,
269270
dataExpression,
270271
plugin,

packages/openapi-ts/src/plugins/@hey-api/transformers/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { IR } from '@hey-api/shared';
22
import type { DefinePlugin, Plugin } from '@hey-api/shared';
33
import type ts from 'typescript';
44

5-
import type { $, MaybeTsDsl, TsDsl } from '../../../ts-dsl';
5+
import type { $, DollarTsDsl, MaybeTsDsl, TsDsl } from '../../../ts-dsl';
66

7-
interface BaseTransformer {
7+
interface BaseTransformer extends DollarTsDsl {
88
plugin: HeyApiTransformersPlugin['Instance'];
99
schema: IR.SchemaObject;
1010
}

packages/openapi-ts/src/plugins/@hey-api/typescript/v1/walker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function createVisitor(
9494
const transformersPlugin = ctx.plugin.getPlugin('@hey-api/transformers');
9595
if (transformersPlugin?.config.typeTransformers) {
9696
for (const typeTransformer of transformersPlugin.config.typeTransformers) {
97-
const typeNode = typeTransformer({ plugin: transformersPlugin, schema });
97+
const typeNode = typeTransformer({ $, plugin: transformersPlugin, schema });
9898
if (typeNode) {
9999
return { meta: defaultMeta(schema), type: typeNode };
100100
}

0 commit comments

Comments
 (0)