Injecting a defined TS type into an unknown generated type? #2444
Replies: 2 comments 1 reply
-
There isn't an officially supported way to inject or override generated types with your own TypeScript types after generation in openapi-ts. The recommended approach for customizing generated types is to use the plugin system, which lets you hook into the generation process and programmatically manipulate operation and schema models, or even emit your own TypeScript types using the TypeScript Compiler API. This happens during generation, not after, and requires writing a custom plugin and registering it in your config (docs). Directly editing generated files like If you want to maintain your own types alongside the generated ones, you could use type aliasing or wrapper types in your codebase, but this would be a manual mapping and not a true injection or override. For full control, a custom plugin is the way to go. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@bombillazo can you show an example of what you're trying to do? I'm pretty sure this is a feature request but want to see the specific problem and maybe the solution will become obvious |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, me again 😄.
I want to be able to inject a TS type we have defined in code into a specific generated type. At teh moment we have a Spec we do not control but have typed our own TS type and want to map it directly to the generated types.gen types so that clients have the typing responses.
Patching via parser would require us to reimplement the types in the OpenAPI spec, which would be tedious (although technically the proper approach).
How can we inject those types into the generated types post-generation?
Beta Was this translation helpful? Give feedback.
All reactions