hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.24k stars 96 forks source link

Add JSDOC tags to generated type declarations #1119

Open robogeek opened 2 weeks ago

robogeek commented 2 weeks ago

Description

The type declarations generated by openapi-ts are very good.

They would be even more useful if they had JSDOC tags.

The information for JSDOC tags is readily available in an OpenAPI spec. This would open the door to using the output with tools that can consume JSDOC tags - such as documentation generation - tooltips in the IDE

mrlubos commented 2 weeks ago

Hey @robogeek can you provide a specific example where the generated code falls short and what you'd expect to see?

sberryman-mh commented 2 weeks ago

I'm also interested in this feature. I use ts-to-zod to generate zod schemas based on openapi-ts generated types. Since there are no jsdoc tags in the output I'm not getting validators or defaults in my zod schemas.

Funny timing, I just saw this PR @mrlubos - https://github.com/hey-api/openapi-ts/pull/1127

mrlubos commented 2 weeks ago

@sberryman-mh I swear that's how it goes every time haha. Want to help me beta test https://github.com/hey-api/openapi-ts/issues/876?

sberryman-mh commented 2 weeks ago

@mrlubos - I'm happy to help test it. I do use ts-to-zod config, specifically nameFilter as I don't need (name.endsWith OpenApiTs, Response and Error schemas)

Is the approach to bring this in-house vs instructing users to use ts-to-zod (while adding jsdoc tags) easier in the long run? That project has a pretty good following

mrlubos commented 2 weeks ago

@sberryman-mh Which OpenAPI version are you on?

sberryman-mh commented 2 weeks ago

@mrlubos 3.1 - most of our backend API's are in python/FastAPI