Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#6,986 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
openapi, php, symfony
领域
api, backend

调研方向

从 ApiResource 的主机元数据 OpenAPI 文档生成入口开始,使用报告中描述的 tenant 和 main-domain API 文档。比较两个主机生成的规范;完成的标准是,受主机限制的端点不会出现在 tenant 文档中,并且 server URL 反映适用的主机。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
PHP
星标
2.6k
派生
989
平均合并
1 天 22 小时
30 天内合并 PR
100

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

api-platform/core 的其他 Issue

查看 api-platform/core 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。