api-platform / api-platform/core

OpenAPI (Swagger) documentation does not take into account the routes hostname

未關閉
#6,986 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
PHP
星號
2.6k
分支
980
平均合併
2 天 5 小時
30 天內合併 PR
48

描述

**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:
```yml
# 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
# .env
APP_HOST="example.com"
```

When I specify the host used for an ApiResource, for instance:
```php
#[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](https://swagger.io/docs/specification/api-host-and-base-path/).

**Additional Context**
Ask if necessary

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。