Open Siyer2 opened 1 year ago
tl;dr when my schema has something like this in it:
image: z.function().returns(ImageSchema)
it displays as image: {} with no details on ImageSchema.
image: {}
ImageSchema
My implementation: I try to go from Zod to OpenAPI like this:
import { extendApi, generateSchema } from '@anatine/zod-openapi'; import { MySchema } from '../../typed/MySchema'; const openApiFile: any = { openapi: '3.0.0', info: { title: 'Schemas', version: '0.0.0', }, components: { schemas: {}, }, paths: {}, }; // Generate the schema const mySchemaOpenApi = generateSchema(extendApi(MySchema)); openApiFile.components.schemas.MySchema = mySchemaOpenApi; // Add my path const myPath = {...} openApiFile.paths['/somepath'] = myPath; // Push OpenAPI file mkdirSync('data/', { recursive: true }); writeFileSync(`data/openapi.json`, JSON.stringify(openApiFile));
My schema looks like this:
export const MySchema = z.object({ image: z.function().returns(ImageSchema) });
But when I run this, wherever there is a z.function().returns(...), it simply returns {} rather than showing the ImageSchema. Is there anyway to fix this?
{}
tl;dr when my schema has something like this in it:
it displays as
image: {}
with no details onImageSchema
.My implementation: I try to go from Zod to OpenAPI like this:
My schema looks like this:
But when I run this, wherever there is a z.function().returns(...), it simply returns
{}
rather than showing theImageSchema
. Is there anyway to fix this?