API Platform version(s) affected: ^3.1
Description
I have endpoints that needs to be accessible from different hosts for a multi-tenant app.
On the main domain (example.com/api), there are common data endpoints.
For tenant subdomain (tenant_identifier.example.com/api), there are the tenant data endpoints.
I tried to restrict the common data endpoints with the host parameter and it works as expected but the endpoints does not disappear from the tenant API documentation (tenant_identifier.example.com/api/docs). Therefore, the host does not seems to be taken into account for the OpenAPI specification.
How to reproduce
I have the following service configuration to inject the hostname dynamically:
# config/services.yaml
parameters:
# Used for route host matching as %env(...)% syntax is not supported
# @see https://stackoverflow.com/questions/47165113/environment-variables-in-route-annotations
hostname: '%env(resolve:APP_HOST)%'
# .env
APP_HOST="example.com"
When I specify the host used for an ApiResource, for instance:
#[ApiResource(
// ...
host: '%hostname%',
// ...
)]
class FooBar
The endpoints are still available from the tenant API documentation (tenant_identifier.example.com).
Possible Solution
The server url should be taken into account as it's shown in the OpenAPI specification.
Additional Context
Ask if necessary
API Platform version(s) affected: ^3.1
Description
I have endpoints that needs to be accessible from different hosts for a multi-tenant app.
On the main domain (
example.com/api), there are common data endpoints.For tenant subdomain (
tenant_identifier.example.com/api), there are the tenant data endpoints.I tried to restrict the common data endpoints with the
hostparameter and it works as expected but the endpoints does not disappear from the tenant API documentation (tenant_identifier.example.com/api/docs). Therefore, thehostdoes not seems to be taken into account for the OpenAPI specification.How to reproduce
I have the following service configuration to inject the hostname dynamically:
When I specify the host used for an ApiResource, for instance:
#[ApiResource( // ... host: '%hostname%', // ... )] class FooBarThe endpoints are still available from the tenant API documentation (
tenant_identifier.example.com).Possible Solution
The server url should be taken into account as it's shown in the OpenAPI specification.
Additional Context
Ask if necessary