Swagger document different property content for POST and GET requests
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- openapi, php
- 领域
- api, documentation
调研方向
首先使用 PlaceOpportunityUsage 示例及其 ApiProperty、Groups 和嵌套规范化行为,复现 ApiPlatform 3.2 上 POST 和 GET 操作生成的 Swagger/OpenAPI 输出。跟踪操作 schema 和属性示例的生成方式,然后验证是否能够表示操作特定的 IRI 示例和嵌套属性示例。完成的标准是支持不同的 POST/GET 输出,或明确记录该限制。
由索引模型根据 Issue 内容生成。
描述
We are using ApiPlatform for 2 years to develop our API. Some properties are (denormalized/normalized) different like on write using IRI reference but on read show nested properties instead.
Even we can update and set the iri reference example on the property like:
class PlaceOpportunityUsage extends AbstractEntityHasId
{
/**
* @var PlaceOpportunity|null
*/
#[ORM\ManyToOne(targetEntity: PlaceOpportunity::class)]
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
#[ApiProperty(example: '/api/opportunities/{id}')]
#[Groups(['OpportunityUsage:write', 'OpportunityUsage:read'])]
private ?PlaceOpportunity $opportunity = null;
We think ApiPlatform has feature to automatically set the IRI reference and put to property example without explicitly specify. Also when we set example like that, on each request body/response this property appears as large. But some requests normalizing this property as nested and returns nested object like that:
{
"@id": "/api/opportunity/usages/10",
"@type": "PlaceOpportunityUsage",
"opportunity": {
"@id": "/api/instant/opportunities/31",
"@type": "PlaceOpportunity",
"status": true,
"place": {
"@id": "/api/places/2ffeab17-13d8-458a-abf8-f20d3ba7a08f",
"@type": "Place",
"name": "Uncle Wingman",
"id": "2ffeab17-13d8-458a-abf8-f20d3ba7a08f",
"createdAt": "2025-07-08",
"updatedAt": "2026-05-11"
},
"dayInterval": [
"MONDAY",
"TUESDAY",
"FRIDAY",
"SATURDAY"
],
....
},
....
}
I want to show different examples on POST or GET requests. When I remove the #[ApiProperty] attribute on the property, at this time the request shows that property example as http://example.com, because we couldn't find documentation about iris property in the ApiProperty instance, we tought field for setting reference examples this didn't work.
We are using ApiPlatform 3.2, and we cannot update our version yet.
Is there a way to fix this issue?
- 主要语言
- PHP
- 星标
- 2.6k
- 派生
- 987
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 90
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/core 的其他 Issue
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1未关闭
难度 2/5 1-3 小时 新手友好度 76/100
api-platform/core#8650 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
api-platform/core#8649 ·
维护者通常 1 天内回复
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7未关闭
难度 2/5 1-3 小时 新手友好度 78/100
api-platform/core#8648 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
api-platform/core#8647 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
api-platform/core#8612 ·
维护者通常 1 天内回复
查看 api-platform/core 的全部 Issue
相似的 Issue
-
sync-en
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 4 天内回复
-
Перевод устарел
难度 2/5 1-3 小时 新手友好度 70/100
-
Combination form: image thumbnails collapse to 0×0 when a stylesheet sets `img { max-width: 100% }`未关闭
难度 2/5 1-3 小时 新手友好度 66/100
PrestaShop/PrestaShop#43200 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
roadrunner-php/cli#69 ·
维护者通常 1 天内回复