Replies: 17 comments
-
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! |
Beta Was this translation helpful? Give feedback.
-
You didn't understand: I want to have separated APIs — one public, one internal. How do you recommend to achieve this? |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
But how about swagger docs? And is this possible to have some common logic if two kernels are being used? |
Beta Was this translation helpful? Give feedback.
-
Just have 2 separate apps, but you can structure your code for reuse between the 2 apps. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
What about keeping them as a single API then? But using different prefixes as @dunglas has suggested. |
Beta Was this translation helpful? Give feedback.
-
But they will share Swagger docs what is the thing I don't want to. |
Beta Was this translation helpful? Give feedback.
-
You could decorate the Docker normalizer to filter the docs by prefix. |
Beta Was this translation helpful? Give feedback.
-
And then, how to access two swagger-based functionality — eg. API website and generate separated |
Beta Was this translation helpful? Give feedback.
-
Same, decorate the documentation normalizer accordingly and allow only the prefixed data. |
Beta Was this translation helpful? Give feedback.
-
I know but how to access first and second one (mean how to distinguish which one I want to get/open at time)? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
Bundled: https://github.com/er1z/multi-api-platform-bundle My question, how to create unit-tests against such a decoration? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions