Multiple APIs in the same project
Very nice lib, thank you for spending time on this.
I'm using the lib in an Expo project, where I call a Gateway application which routes requests to multiple backend services. Is it possible to create separate clients for those backends?
Atm. I have "codegen": "openapi-rq -i http://localhost:8082/v3/api-docs --base http://localhost:8080/svc/a -c axios --format prettier ", which is generating the code for the service behind port 8082, with a base URL pointing to service a. How could I add another service here? My main problem is that creating a second service will create second static OpenAPI object which I have to configure identically to the one from service a.
@HJK181
Is it possible to generate code for each service using the --output option?
a:
openapi-rq -i http://localhost:8082/v3/api-docs --base http://localhost:8080/svc/a -c axios --format prettier --output openapi-a
b:
openapi-rq -i http://localhost:8082/v3/api-docs --base http://localhost:8080/svc/b -c axios --format prettier --output openapi-b
@HJK181
Is it possible to generate code for each service using the
--outputoption?a:
openapi-rq -i http://localhost:8082/v3/api-docs --base http://localhost:8080/svc/a -c axios --format prettier --output openapi-ab:
openapi-rq -i http://localhost:8082/v3/api-docs --base http://localhost:8080/svc/b -c axios --format prettier --output openapi-b
But this gives me two static OpenAPI objects in two folder’s right? Than, I have to set the same bearer token and interceptors on two independent objects instead of one?
@HJK181 Perhaps the exportCore option from @hey-api/openapi-ts could be useful. Try generating OpenAPI.ts with exportCore=true once, and then run it with exportCore=false afterwards. OpenAPI.ts won't be overwritten. By exporting the same object, you should be able to use it across multiple services.
In this library, the exportCore option is fixed to true, so I need to fix it.
Will this be fixed in the next major version?