Best approach for scaling a strongly-typed API suite
I have the same object that needs to be used across multiple SDKs.
Say the yaml file for ServiceA contains Object1 and I want to use it in the ServiceB yaml file.
In the ServiceB file I easily reference Object1 with $ref: ./service-a.yaml#/components/schemas/Object1, however when generating the SDKs for each service separately there are two different objects. (This is appropriate.)
When using this in an application where serviceA calls serviceB I can't pass serviceA.models.Object1 into the serviceB API because it will throw a type error. It is expecting serviceB.models.Object1.
To solve for this I know of two approaches:
1. Create extension functions to convert serviceA Object1 to serviceB Object1. This doesn't scale nicely if one has many reusable objects across many services.
2. Import all the paths into a single file and just generate the main file. This scales but there are two concerns.
i. When importing the SDK into an application I am importing all APIs (over 300+), as a result the import is a lot larger then it should to be.
ii. I have to create two paths for each API, one in the service file and one in the main file.
Question: Is there a more appropriate way to solve for this?