OpenAPI missing request schema when providing MediaType examples
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by reproducing with the EntityResource class and the POST operation's custom openapi RequestBody from the issue, then inspect the generated OpenAPI output for that request body. The bug is that providing MediaType examples drops the schema, so the first question is where the custom MediaType replaces the generated one. Done when the request body keeps the resource schema alongside the examples, and the maintainers have settled whether the merge approach proposed in the issue is acceptable.
由索引模型根据 Issue 内容生成。
描述
API Platform version(s) affected: 5.0.2
Description
Documenting requestBody examples removes the request format schemas
How to reproduce
Using the following ApiResource class:
#[Post(
status: 201,
openapi: new Operation(
requestBody: new RequestBody(
content: new ArrayObject(
[
'application/ld+json' => new MediaType(
examples: new ArrayObject(
[
'hello world' => new Example(description: 'Submitting a "hello world" entity', value: new EntityResource(1, 'Hello world')),
'foo bar' => new Example(description: 'Submitting a "foo bar" entity', value: new EntityResource(2, 'Foo bar')),
],
),
),
],
),
),
),
)]
readonly class EntityResource
{
public function __construct(#[ApiProperty(identifier: true)] public int $id, public string $name)
{
}
}
The schema is missing from the generated spec:
SwaggerUI output
And I have to add it myself, but this risks documentation drift caused by future API updates.
new ArrayObject(
[
'type' => 'object',
'properties' => new ArrayObject(
[
'id' => new ArrayObject(['type' => 'integer']),
'name' => new ArrayObject(['type' => 'string']),
],
),
],
),
SwaggerUI output
Additional
Would it be possible/okay to merge the API-Platform generated MediaType with the APIResource's MediaType? And only fill in the null values?
- 主要语言
- PHP
- 星标
- 2.6k
- 派生
- 988
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 108
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/core 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
api-platform/core#8744 ·
维护者通常 1 天内回复
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`可能已有人在做 @ousamabenyounes 于 6 天前认领。 未关闭
难度 2/5 1 小时以内 新手友好度 80/100
api-platform/core#8701 ·
维护者通常 1 天内回复
-
[Json-Schema] Nested resources lost externalDoc and description data可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
api-platform/core#8721 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 50/100
api-platform/core#8704 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 62/100
api-platform/core#8703 ·
维护者通常 1 天内回复
查看 api-platform/core 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
PHP SDK drops the API path prefix when a custom base URL has no trailing slash可能已有人在做 @Winoren 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
langgenius/dify#44568 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
1. to develop bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复