chargebee-typescript icon indicating copy to clipboard operation
chargebee-typescript copied to clipboard

Suggest to try Stainless-API

Open johnpyp opened this issue 1 year ago • 4 comments

I see the chargebee SDK is clearly autogenerated. I'm just a Chargebee customer, but a lot of big companies have been picking up https://www.stainlessapi.com/ as their SDK generator of choice. It generates really high quality APIs, which can help modernize a lot of the code. I see a lot of patterns that could use some help in the various chargebee SDKs.

johnpyp avatar Apr 27 '24 05:04 johnpyp

Hey @johnpyp, Sriram here from the DX team at Chargebee. Thanks for your suggestion. Appreciate you taking the time to share this.

While I can't comment on using Stainless or any 3rd party SDK generators at this time, I'd love to understand what you think could be improved in our SDKs and the patterns that you're referring to above. Please share here or feel free to send me an email (address in my profile). Thanks!

cb-sriramthiagarajan avatar Apr 27 '24 09:04 cb-sriramthiagarajan

Yeah, just to name a couple:

  • Using snake_case in Typescript/JS (where camelCase is the norm), but also mixing with camel case strangely
  • Lack of API comments annotating methods or model types (even though the openapi spec does specify them)
  • Use of callback apis for asynchronous code - Promises have been the standard in JS/TS for at least 4-5 years now, so it shows a fair bit of age and is quite annoying to use in modern code.
  • Using let when const would suffice
  • Callback error types aren't actual errors, they're just objects.
  • Weird interface exports like:
  export interface payment_method_update_params {
    gateway_account_id?: string;
  }
  export interface payment_method_update_params {
    reference_id?: string;
  }
  export interface payment_method_update_params {
    tmp_token?: string;
  }
  export interface payment_method_update_params {
    issuing_country?: string;
  }
  export interface payment_method_update_params {
    additional_information?: any;

(These are all the same export, and it's relying on interface merging, which is a really strange pattern)


Now, I see Chargebee has actually relatively recently started publishing an OpenAPI spec - https://github.com/chargebee/openapi

It seems to me that this spec has everything needed to generate a great api with all the modern conventions, comments, etc.

The reason I suggest stainless is because they basically take care of everything for you, and they're trusted by some of the largest new tech companies like OpenAI, Cloudflare, Anthropic, etc. - I imagine for a company like chargebee it'd be a small cost to pilot to see if it's helpful for customers.

Of course, it would be a massive breaking change, so it'd have to be new libraries, which is probably the biggest downside I suppose. However, at least the JS SDKs seem to need significant modernization anyways, if I'm being honest.

johnpyp avatar Apr 27 '24 09:04 johnpyp

Thanks a lot for the detailed note, @johnpyp. Agree that these need to be fixed.

You're right, our OpenAPI spec has everything needed for the SDK and we're in the process of using it as the base without changing much in the SDK itself. We'll work on how these things can be improved without a lot of breaking changes. I'll get back with an update soon.

cb-sriramthiagarajan avatar Apr 27 '24 09:04 cb-sriramthiagarajan

Hi @johnpyp, we have released a new beta version which addresses the issues you have mentioned. It'd be great if you could try it and share your feedback.

You can install this using npm install chargebee@beta

Edit: We have a Migration guide for v3. README in the next branch also has more info on the usage.

cb-sriramthiagarajan avatar Aug 26 '24 07:08 cb-sriramthiagarajan