hey-api / openapi-ts

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

feature: tree-shaking but supporting namespaced services #1168

Open rubenfiszel opened 1 month ago

rubenfiszel commented 1 month ago

Description

This project used to namespace operations by service which was very nice:

FooService.myOperation(foo)

However, the default is now to have everything at the top-level without a per-service namespace. The new generation use top level consts, which allow for tree-shaking, especially useful for large apis and bundler. Windmill has an extremely large API https://github.com/windmill-labs/windmill and use this for its typescript-client.

It seems to me that keeping the old namespaced methods and tree-shaking are compatible, it would just require writing top-level objects. The reason tree-shaking doesn't work with the old generation is that it's class + method based, not that it's namespaced. An example of a generation that would be compatible with tree-shaking:

export const FooService {
    myOperation: (data) => { ... },
    myOperation2: ...
}

We are happy to contribute to the codebase and add that as a feature, we just wanted to discuss the feature first and if there were any objections.

mrlubos commented 1 month ago

Hey @rubenfiszel, sent you a request on LinkedIn, would like to ask a few things!