Common Schemas docs
Define reusable schema components that can be referenced across your OpenAPI specification (Only support zod 3 and 4 for now):
const UserSchema = z.object({
id: z.string(),
name: z.string(),
email: z.string().email(),
})
const PetSchema = z.object({
id: z.string().transform(id => Number(id)).pipe(z.number()),
})
const spec = await generator.generate(router, {
commonSchemas: {
User: {
schema: UserSchema,
},
InputPet: {
strategy: 'input',
schema: PetSchema,
},
OutputPet: {
strategy: 'output',
schema: PetSchema,
},
},
})
🚀 Features
- openapi: Gen spec with common schemas -
components.schemas
- by @unnoq in #638 (bd95e) - server: Optimize encodeHibernationRPCEvent - by @unnoq (ec7d8)
🐞 Bug Fixes
- openapi: OpenAPIGenerator make response headers optional when headers object is optional - by @unnoq in #642 (5b223)