hey-api / openapi-ts

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

Reintroduce ability to generate types in seperate files #760

Open Nicolas-Yazzoom opened 3 months ago

Nicolas-Yazzoom commented 3 months ago

Description

Coming from openapi-typescript-codegen, it's sad to see that generating seperate files per type is no longer possible since v0.31.0. I've seen issue #357 and read the arguments against this approach, but I also believe it offers some advantages over a single file from a dev ex point of view:

As mentioned in the other ticket, it's a question of preference. Both approached offer advantages and disadvantages and it often boils down to the specific project you're working on. Reintroducing seperate files as an option would be a killer feature. They could even be reexported from the existing files to minimize friction when deciding the best approach for your current project.

It might look something like this:

export default defineConfig({
    output: {
        // Set in output for preferred global behavior.
        // Current behavior "merged" can remain default.
        files: 'merged' | 'seperate' 
    },
    types: {
        // Ability to set specifically for types, services, ...
        files: "merged" | "seperate" 
    },
})
mrlubos commented 3 months ago

Hey @Nicolas-Yazzoom, not against this as a feature, but certainly not a priority so would most likely need someone to help out