asteasolutions / zod-to-openapi

A library that generates OpenAPI (Swagger) docs from Zod schemas
MIT License
955 stars 60 forks source link

zodSchema.openapi is not a function #265

Closed arthurvanl closed 3 hours ago

arthurvanl commented 2 weeks ago
TypeError: zodSchema.openapi is not a function. (In 'zodSchema.openapi(refId)', 'zodSchema.openapi' is undefined)
      at C:\Users\xxxx\Desktop\programs\openapi-builder\node_modules\@asteasolutions\zod-to-openapi\dist\index.cjs:332:26
      at register (C:\Users\xxxx\Desktop\programs\openapi-builder\node_modules\@asteasolutions\zod-to-openapi\dist\index.cjs:275:38)
      at generateSchemaObject (C:\Users\xxxx\Desktop\programs\openapi-builder\src\utils\index.ts:44:18)
      at toJSON (C:\Users\xxxx\Desktop\programs\openapi-builder\src\builders\request_body.ts:89:22)
      at toJSON (C:\Users\xxxx\Desktop\programs\openapi-builder\src\builders\path.ts:226:68)
      at toJSON (C:\Users\xxxx\Desktop\programs\openapi-builder\src\builders\path.ts:60:88)
      at C:\Users\xxxx\Desktop\programs\openapi-builder\src\builders\openapi.ts:171:48
      at reduce (1:11)
      at toJSON (C:\Users\xxxx\Desktop\programs\openapi-builder\src\builders\openapi.ts:170:35)
      at C:\Users\xxxx\Desktop\programs\openapi-builder\src\tests\setup.ts:139:55

I am calling extendZodWithOpenApi(z);

in every file now because I thought it was not loaded in a file. But still no progress. Any Tips?

AGalabov commented 1 day ago

@arthurvanl can you provide us with an example to recreate it? My best guess is that it is a particular incorrect usage that is causing this error.

arthurvanl commented 3 hours ago

I actually already switched to an other package. Sorry