openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Full SDK generator

Open mrlubos opened this issue 1 year ago • 4 comments

Description

This would be the successor to what's currently the name config option.

Related

  • https://github.com/hey-api/openapi-ts/issues/671
  • https://github.com/orgs/hey-api/discussions/619

Let's gauge interest before committing to this feature

mrlubos avatar Aug 14 '24 08:08 mrlubos

After using the current deprecated name implementation, some desired features are:

  • Keep the transient SDK, where one can invoke new individual instances of the SDK where needed. This differs from the singleton pattern which is beneficial more for Front End clients
  • Replace name config option with something more meaningful, perhaps a property inside config output called sdk which can be boolean or string. if set to bool, the codegen produces the full SDK version of the code with a default name, which a string would do the same but override the SDK name.
  • Compatibility with the @hey-api/client-fetch by default. The current Fetch implementation is missing some great features:
    • first-class support by hey-api
    • allow to pass request overrides per method calls, which is something awesome
  • Compatibility with flat and class. The current implementation is only for class, while flat could lift all methods to the root level of the SDK

Im willing to contribute to this and help flesh these out

bombillazo avatar Aug 15 '24 00:08 bombillazo

"Let's gauge interest before committing to this feature"

Very interested, the ability to generate an extendable SDK from openapi would be extremely useful.

const example = exampleClient()

const site = await example.getSite('uuid')

Would be amazing. I have tried openapi-generator-cli but it is a lot more difficult.

Ideally I could extend as well to add custom validation logic

await example.patchPage({id: '', html: ''})

Where I validate the HTML is correct.

volkandkaya avatar Sep 15 '24 04:09 volkandkaya

:wave: This is what I was using openapi-ts for originally, and loved it. A single client. I'll be pinned on 0.53.9 for now.

For context I use this as a nodejs client, so i have an app, say app-a that has a build process that also produces a typed client for app-a which i publish to npm. Then app-b can npm install app-aand doconst client = new AppA()` to interact with it.

The other thing is dependency injection & teseting, it's far easier for me to stub out a single client such as this in app-b than a whole bunch of individual functions.

Stono avatar Nov 13 '24 14:11 Stono

🌝

Discussion for my reference: https://github.com/orgs/hey-api/discussions/619

mrlubos avatar Apr 02 '25 08:04 mrlubos

Hey all, the initial iteration will be available in the next release! I KNOW there will be many bugs, please open new issues for those 🙌

mrlubos avatar Jun 05 '25 10:06 mrlubos

Thats awesome!!! Great work , excited to try it out.

bombillazo avatar Jun 05 '25 12:06 bombillazo

I just tried the instance option, so far works as expected!

bombillazo avatar Jul 17 '25 12:07 bombillazo