Skip to content

Commit 62a4745

Browse files
committed
feat: add resolvers keyword
1 parent 202c765 commit 62a4745

File tree

56 files changed

+774
-771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+774
-771
lines changed

.changeset/early-frogs-hear.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+
**valibot**: allow generating custom pipes with `~resolvers`

.changeset/eight-eagles-shop.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+
**zod**: allow generating custom chains with `~resolvers`

dev/openapi-ts.config.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ export default defineConfig(() => {
4141
// 'circular.yaml',
4242
// 'dutchie.json',
4343
// 'invalid',
44-
'full.yaml',
44+
// 'full.yaml',
4545
// 'openai.yaml',
4646
// 'opencode.yaml',
4747
// 'sdk-instance.yaml',
4848
// 'string-with-format.yaml',
49-
// 'transformers.json',
49+
'transformers.json',
5050
// 'type-format.yaml',
5151
// 'validators.yaml',
5252
// 'validators-circular-ref.json',
@@ -269,8 +269,8 @@ export default defineConfig(() => {
269269
// signature: 'client',
270270
// signature: 'object',
271271
// transformer: '@hey-api/transformers',
272-
// transformer: true,
273-
// validator: true,
272+
transformer: true,
273+
validator: 'zod',
274274
// validator: {
275275
// request: 'zod',
276276
// response: 'zod',
@@ -291,8 +291,8 @@ export default defineConfig(() => {
291291
},
292292
{
293293
// bigInt: true,
294-
// dates: true,
295-
// name: '@hey-api/transformers',
294+
dates: true,
295+
name: '@hey-api/transformers',
296296
},
297297
{
298298
// name: 'fastify',
@@ -395,11 +395,19 @@ export default defineConfig(() => {
395395
// },
396396
},
397397
},
398+
'~resolvers': {
399+
string: {
400+
formats: {
401+
// date: ({ $, pipes }) => pipes.push($('v').attr('isoDateTime').call()),
402+
// 'date-time': ({ $, pipes }) => pipes.push($('v').attr('isoDateTime').call()),
403+
},
404+
},
405+
},
398406
},
399407
{
400408
// case: 'snake_case',
401409
// comments: false,
402-
compatibilityVersion: 4,
410+
compatibilityVersion: 3,
403411
dates: {
404412
// local: true,
405413
// offset: true,
@@ -447,6 +455,14 @@ export default defineConfig(() => {
447455
// },
448456
},
449457
},
458+
'~resolvers': {
459+
string: {
460+
formats: {
461+
// date: ({ $ }) => $('z').attr('date').call(),
462+
// 'date-time': ({ $ }) => $('z').attr('date').call(),
463+
},
464+
},
465+
},
450466
},
451467
{
452468
exportFromIndex: true,

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,13 @@ export const vModelSquare = v.object({
412412
export const vCompositionWithOneOfDiscriminator = v.union([
413413
v.intersect([
414414
v.object({
415-
kind: v.literal('circle')
415+
kind: v.literal("circle")
416416
}),
417417
vModelCircle
418418
]),
419419
v.intersect([
420420
v.object({
421-
kind: v.literal('square')
421+
kind: v.literal("square")
422422
}),
423423
vModelSquare
424424
])

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ export const vModelSquare = v.object({
415415
export const vCompositionWithOneOfDiscriminator = v.union([
416416
v.intersect([
417417
v.object({
418-
kind: v.literal('circle')
418+
kind: v.literal("circle")
419419
}),
420420
vModelCircle
421421
]),
422422
v.intersect([
423423
v.object({
424-
kind: v.literal('square')
424+
kind: v.literal("square")
425425
}),
426426
vModelSquare
427427
])
@@ -467,7 +467,7 @@ export const v3eNum1Период = v.picklist([
467467
'Dog'
468468
]);
469469

470-
export const vConstValue = v.literal('ConstValue');
470+
export const vConstValue = v.literal("ConstValue");
471471

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

723723
export const vModelWithConst = v.object({
724-
String: v.optional(v.literal('String')),
724+
String: v.optional(v.literal("String")),
725725
number: v.optional(v.literal(0)),
726726
null: v.optional(v.null()),
727-
withType: v.optional(v.literal('Some string'))
727+
withType: v.optional(v.literal("Some string"))
728728
});
729729

730730
/**
@@ -1660,9 +1660,9 @@ export const vTypesData = v.object({
16601660
v.null()
16611661
]),
16621662
parameterEnum: v.union([
1663-
v.literal('Success'),
1664-
v.literal('Warning'),
1665-
v.literal('Error'),
1663+
v.literal("Success"),
1664+
v.literal("Warning"),
1665+
v.literal("Error"),
16661666
v.null()
16671667
])
16681668
})

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as v from 'valibot';
44

55
export const vFoo = v.object({
6-
foo: v.optional(v.literal('foo')),
6+
foo: v.optional(v.literal("foo")),
77
bar: v.optional(v.literal(3.2)),
88
baz: v.optional(v.literal(-1)),
99
qux: v.optional(v.literal(true)),

packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/circular/zod.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ export const zBaz = z.object({
3333

3434
export const zQux = z.union([
3535
z.intersection(z.object({
36-
type: z.literal('struct')
36+
type: z.literal("struct")
3737
}), z.lazy(() => {
3838
return z.lazy((): any => {
3939
return zCorge;
4040
});
4141
})),
4242
z.intersection(z.object({
43-
type: z.literal('array')
43+
type: z.literal("array")
4444
}), zFoo)
4545
]);
4646

packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,10 @@ export const zModelSquare = z.object({
452452
*/
453453
export const zCompositionWithOneOfDiscriminator = z.union([
454454
z.intersection(z.object({
455-
kind: z.literal('circle')
455+
kind: z.literal("circle")
456456
}), zModelCircle),
457457
z.intersection(z.object({
458-
kind: z.literal('square')
458+
kind: z.literal("square")
459459
}), zModelSquare)
460460
]);
461461

packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/circular/zod.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export const zBaz: z.AnyZodObject = z.object({
2525

2626
export const zQux: z.ZodTypeAny = z.union([
2727
z.object({
28-
type: z.literal('struct')
28+
type: z.literal("struct")
2929
}).and(z.lazy(() => {
3030
return zCorge;
3131
})),
3232
z.object({
33-
type: z.literal('array')
33+
type: z.literal("array")
3434
}).and(zFoo)
3535
]);
3636

packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ export const zModelSquare = z.object({
450450
*/
451451
export const zCompositionWithOneOfDiscriminator = z.union([
452452
z.object({
453-
kind: z.literal('circle')
453+
kind: z.literal("circle")
454454
}).and(zModelCircle),
455455
z.object({
456-
kind: z.literal('square')
456+
kind: z.literal("square")
457457
}).and(zModelSquare)
458458
]);
459459

0 commit comments

Comments
 (0)