这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/early-frogs-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

**valibot**: allow generating custom pipes with `~resolvers`
5 changes: 5 additions & 0 deletions .changeset/eight-eagles-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

**zod**: allow generating custom chains with `~resolvers`
30 changes: 23 additions & 7 deletions dev/openapi-ts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default defineConfig(() => {
// 'circular.yaml',
// 'dutchie.json',
// 'invalid',
'full.yaml',
// 'full.yaml',
// 'openai.yaml',
// 'opencode.yaml',
// 'sdk-instance.yaml',
// 'string-with-format.yaml',
// 'transformers.json',
'transformers.json',
// 'type-format.yaml',
// 'validators.yaml',
// 'validators-circular-ref.json',
Expand Down Expand Up @@ -269,8 +269,8 @@ export default defineConfig(() => {
// signature: 'client',
// signature: 'object',
// transformer: '@hey-api/transformers',
// transformer: true,
// validator: true,
transformer: true,
validator: 'zod',
// validator: {
// request: 'zod',
// response: 'zod',
Expand All @@ -291,8 +291,8 @@ export default defineConfig(() => {
},
{
// bigInt: true,
// dates: true,
// name: '@hey-api/transformers',
dates: true,
name: '@hey-api/transformers',
},
{
// name: 'fastify',
Expand Down Expand Up @@ -395,11 +395,19 @@ export default defineConfig(() => {
// },
},
},
'~resolvers': {
string: {
formats: {
// date: ({ $, pipes }) => pipes.push($('v').attr('isoDateTime').call()),
// 'date-time': ({ $, pipes }) => pipes.push($('v').attr('isoDateTime').call()),
},
},
},
},
{
// case: 'snake_case',
// comments: false,
compatibilityVersion: 4,
compatibilityVersion: 3,
dates: {
// local: true,
// offset: true,
Expand Down Expand Up @@ -447,6 +455,14 @@ export default defineConfig(() => {
// },
},
},
'~resolvers': {
string: {
formats: {
// date: ({ $ }) => $('z').attr('date').call(),
// 'date-time': ({ $ }) => $('z').attr('date').call(),
},
},
},
},
{
exportFromIndex: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ export const vModelSquare = v.object({
export const vCompositionWithOneOfDiscriminator = v.union([
v.intersect([
v.object({
kind: v.literal('circle')
kind: v.literal("circle")
}),
vModelCircle
]),
v.intersect([
v.object({
kind: v.literal('square')
kind: v.literal("square")
}),
vModelSquare
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ export const vModelSquare = v.object({
export const vCompositionWithOneOfDiscriminator = v.union([
v.intersect([
v.object({
kind: v.literal('circle')
kind: v.literal("circle")
}),
vModelCircle
]),
v.intersect([
v.object({
kind: v.literal('square')
kind: v.literal("square")
}),
vModelSquare
])
Expand Down Expand Up @@ -467,7 +467,7 @@ export const v3eNum1Период = v.picklist([
'Dog'
]);

export const vConstValue = v.literal('ConstValue');
export const vConstValue = v.literal("ConstValue");

/**
* This is a model with one property with a 'any of' relationship where the options are not $ref
Expand Down Expand Up @@ -721,10 +721,10 @@ export const vFreeFormObjectWithAdditionalPropertiesEqTrue = v.record(v.string()
export const vFreeFormObjectWithAdditionalPropertiesEqEmptyObject = v.record(v.string(), v.unknown());

export const vModelWithConst = v.object({
String: v.optional(v.literal('String')),
String: v.optional(v.literal("String")),
number: v.optional(v.literal(0)),
null: v.optional(v.null()),
withType: v.optional(v.literal('Some string'))
withType: v.optional(v.literal("Some string"))
});

/**
Expand Down Expand Up @@ -1660,9 +1660,9 @@ export const vTypesData = v.object({
v.null()
]),
parameterEnum: v.union([
v.literal('Success'),
v.literal('Warning'),
v.literal('Error'),
v.literal("Success"),
v.literal("Warning"),
v.literal("Error"),
v.null()
])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as v from 'valibot';

export const vFoo = v.object({
foo: v.optional(v.literal('foo')),
foo: v.optional(v.literal("foo")),
bar: v.optional(v.literal(3.2)),
baz: v.optional(v.literal(-1)),
qux: v.optional(v.literal(true)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export const zBaz = z.object({

export const zQux = z.union([
z.intersection(z.object({
type: z.literal('struct')
type: z.literal("struct")
}), z.lazy(() => {
return z.lazy((): any => {
return zCorge;
});
})),
z.intersection(z.object({
type: z.literal('array')
type: z.literal("array")
}), zFoo)
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ export const zModelSquare = z.object({
*/
export const zCompositionWithOneOfDiscriminator = z.union([
z.intersection(z.object({
kind: z.literal('circle')
kind: z.literal("circle")
}), zModelCircle),
z.intersection(z.object({
kind: z.literal('square')
kind: z.literal("square")
}), zModelSquare)
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export const zBaz: z.AnyZodObject = z.object({

export const zQux: z.ZodTypeAny = z.union([
z.object({
type: z.literal('struct')
type: z.literal("struct")
}).and(z.lazy(() => {
return zCorge;
})),
z.object({
type: z.literal('array')
type: z.literal("array")
}).and(zFoo)
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ export const zModelSquare = z.object({
*/
export const zCompositionWithOneOfDiscriminator = z.union([
z.object({
kind: z.literal('circle')
kind: z.literal("circle")
}).and(zModelCircle),
z.object({
kind: z.literal('square')
kind: z.literal("square")
}).and(zModelSquare)
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export const zBaz = z.object({

export const zQux = z.union([
z.object({
type: z.literal('struct')
type: z.literal("struct")
}).and(z.lazy(() => {
return z.lazy((): any => {
return zCorge;
});
})),
z.object({
type: z.literal('array')
type: z.literal("array")
}).and(zFoo)
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ export const zModelSquare = z.object({
*/
export const zCompositionWithOneOfDiscriminator = z.union([
z.object({
kind: z.literal('circle')
kind: z.literal("circle")
}).and(zModelCircle),
z.object({
kind: z.literal('square')
kind: z.literal("square")
}).and(zModelSquare)
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ export const zModelSquare = z.object({
*/
export const zCompositionWithOneOfDiscriminator = z.union([
z.intersection(z.object({
kind: z.literal('circle')
kind: z.literal("circle")
}), zModelCircle),
z.intersection(z.object({
kind: z.literal('square')
kind: z.literal("square")
}), zModelSquare)
]);

Expand Down Expand Up @@ -508,7 +508,7 @@ export const z3eNum1Период = z.enum([
'Dog'
]);

export const zConstValue = z.literal('ConstValue');
export const zConstValue = z.literal("ConstValue");

/**
* This is a model with one property with a 'any of' relationship where the options are not $ref
Expand Down Expand Up @@ -753,10 +753,10 @@ export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string()
export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown());

export const zModelWithConst = z.object({
String: z.optional(z.literal('String')),
String: z.optional(z.literal("String")),
number: z.optional(z.literal(0)),
null: z.optional(z.null()),
withType: z.optional(z.literal('Some string'))
withType: z.optional(z.literal("Some string"))
});

/**
Expand Down Expand Up @@ -1688,9 +1688,9 @@ export const zTypesData = z.object({
z.null()
]),
parameterEnum: z.union([
z.literal('Success'),
z.literal('Warning'),
z.literal('Error'),
z.literal("Success"),
z.literal("Warning"),
z.literal("Error"),
z.null()
])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as z from 'zod/v4-mini';

export const zFoo = z.object({
foo: z.optional(z.literal('foo')),
foo: z.optional(z.literal("foo")),
bar: z.optional(z.literal(3.2)),
baz: z.optional(z.literal(-1)),
qux: z.optional(z.literal(true)),
Expand Down Expand Up @@ -32,6 +32,6 @@ export const zFoo = z.object({
integerUint16: z.optional(z.literal(65535)),
integerUint32: z.optional(z.literal(4294967295)),
integerUint64: z.optional(z.int()),
stringInt64: z.optional(z.literal('-9223372036854775808')),
stringUint64: z.optional(z.literal('18446744073709551615'))
stringInt64: z.optional(z.literal("-9223372036854775808")),
stringUint64: z.optional(z.literal("18446744073709551615"))
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export const zPatchFooData = z.object({
baz: z.optional(z.string())
})),
qux: z.optional(z.iso.date()),
quux: z.optional(z.iso.datetime({
offset: true
}))
quux: z.optional(z.iso.datetime({ offset: true }))
}))
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,10 @@ export const zModelSquare = z.object({
*/
export const zCompositionWithOneOfDiscriminator = z.union([
z.object({
kind: z.literal('circle')
kind: z.literal("circle")
}).and(zModelCircle),
z.object({
kind: z.literal('square')
kind: z.literal("square")
}).and(zModelSquare)
]);

Expand Down Expand Up @@ -506,7 +506,7 @@ export const z3eNum1Период = z.enum([
'Dog'
]);

export const zConstValue = z.literal('ConstValue');
export const zConstValue = z.literal("ConstValue");

/**
* This is a model with one property with a 'any of' relationship where the options are not $ref
Expand Down Expand Up @@ -751,10 +751,10 @@ export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.unknown(
export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.unknown());

export const zModelWithConst = z.object({
String: z.literal('String').optional(),
String: z.literal("String").optional(),
number: z.literal(0).optional(),
null: z.null().optional(),
withType: z.literal('Some string').optional()
withType: z.literal("Some string").optional()
});

/**
Expand Down Expand Up @@ -1686,9 +1686,9 @@ export const zTypesData = z.object({
z.null()
]),
parameterEnum: z.union([
z.literal('Success'),
z.literal('Warning'),
z.literal('Error'),
z.literal("Success"),
z.literal("Warning"),
z.literal("Error"),
z.null()
])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { z } from 'zod';

export const zFoo = z.object({
foo: z.literal('foo').optional(),
foo: z.literal("foo").optional(),
bar: z.literal(3.2).optional(),
baz: z.literal(-1).optional(),
qux: z.literal(true).optional(),
Expand Down Expand Up @@ -32,6 +32,6 @@ export const zFoo = z.object({
integerUint16: z.literal(65535).optional(),
integerUint32: z.literal(4294967295).optional(),
integerUint64: z.number().int().optional(),
stringInt64: z.literal('-9223372036854775808').optional(),
stringUint64: z.literal('18446744073709551615').optional()
stringInt64: z.literal("-9223372036854775808").optional(),
stringUint64: z.literal("18446744073709551615").optional()
});
Loading
Loading