-
-
Notifications
You must be signed in to change notification settings - Fork 906
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
[question] Two APIs inside single app #2275
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
Comments
Bump. |
Using DTO looks good. You can also leverage the new Input/Output feature if you want to have a resource class but different input/output classes. see #2235 for more informations! |
You didn't understand: I want to have separated APIs — one public, one internal. How do you recommend to achieve this? |
I don't think that it's possible yet without having two kernels. Anyway, you can have a single API, but using different paths per resources (some in /internal, and some in /publish for instance) using the |
But how about swagger docs? And is this possible to have some common logic if two kernels are being used? |
Just have 2 separate apps, but you can structure your code for reuse between the 2 apps. |
Yes, but's it's too early for this pre-mature optimization and I'm looking for a solution how to keep these within one app (both APIs share Entities, DTOs). Maintaining two apps is more absorbing than single one (at least at this product stadium). Isn't this possible? |
What about keeping them as a single API then? But using different prefixes as @dunglas has suggested. |
But they will share Swagger docs what is the thing I don't want to. |
You could decorate the Docker normalizer to filter the docs by prefix. |
And then, how to access two swagger-based functionality — eg. API website and generate separated |
Same, decorate the documentation normalizer accordingly and allow only the prefixed data. |
I know but how to access first and second one (mean how to distinguish which one I want to get/open at time)? |
Made something like this: https://github.com/er1z/api-platform-two-apis PoC that separates DTOs: internal and external. CLI:
API Docs:
Based on decoration of provided services and conditional routes. Please review and point how to do it better and what are pitfalls? |
Bundled: https://github.com/er1z/multi-api-platform-bundle My question, how to create unit-tests against such a decoration? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
What do you recommend in order to create API within two contexts using API Platform: first — publicly available one and second: used by microservices within application cluster? To simplify — I rely on DTOs and do not expose any entities directly.
The text was updated successfully, but these errors were encountered: