checkout-sdk-node icon indicating copy to clipboard operation
checkout-sdk-node copied to clipboard

Ship more detailed types? Codegen from OpenAPI-spec?

Open KATT opened this issue 2 years ago • 5 comments

Hey gang!

Looking at the typedefs of this SDK, I see a big void of actual type-safety:

Screenshot 2022-09-12 at 16 23 05

Even looking at the docs I still don't know what different endpoints are supposed to return without actually invoking the call. The problem with that is that we won't have any reconciliation reports in our sandbox environment.

This example above is just in order to showcase and issue and grokking that is a separate issue.

Suggestion: You shouldn't need to manually write the implementation of every endpoint and instead be able to automatically generate a typesafe SDK based on your OpenAPI-schema using something like the openapi-generator.

Automating this would likely:

  • Greatly reduce the amount of effort needed to put into this SDK
  • Improve your quality of life maintaining it
  • Remove inconsistencies between the actual API & this SDK
  • Improve the experience for your customers

KATT avatar Sep 12 '22 14:09 KATT

Hello checkout.com team,

Please don't do typechecking with primitives. Do you manually handle/update your *.d.ts files?

source

TypeScript_ Documentation - Do's and Don'ts

christos97 avatar Sep 13 '22 13:09 christos97

Thanks for the feedback @christos97 Will look into updating this.

ioan-ghisoi-cko avatar Sep 14 '22 16:09 ioan-ghisoi-cko

@KATT The very minimal type defs were intentional. You can use our API reference to see details about the payloads. We are also exploring generators or full types support as well.

ioan-ghisoi-cko avatar Sep 14 '22 16:09 ioan-ghisoi-cko

Type safety reduces the maintenance burden on consumers of SDKs enormously. It would be great to see an improvement as suggested here.

tbartley avatar Sep 29 '22 20:09 tbartley

We will try to implement this improvement soon.

armando-rodriguez-cko avatar Sep 02 '23 07:09 armando-rodriguez-cko