Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple APIs in the same project #129

Open
HJK181 opened this issue Jul 2, 2024 · 4 comments
Open

Multiple APIs in the same project #129

HJK181 opened this issue Jul 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@HJK181
Copy link

HJK181 commented Jul 2, 2024

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.

@7nohe
Copy link
Owner

7nohe commented Aug 6, 2024

@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

@7nohe 7nohe added the question Further information is requested label Aug 6, 2024
@HJK181
Copy link
Author

HJK181 commented Aug 6, 2024

@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

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?

@7nohe
Copy link
Owner

7nohe commented Aug 7, 2024

@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.

@7nohe 7nohe added enhancement New feature or request and removed question Further information is requested labels Aug 7, 2024
@bryanjtc
Copy link
Contributor

Will this be fixed in the next major version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants