allOf validation not working?
还没有人认领这个 Issue。
评估
调研方向
使用提供的 OpenAPI 文档以及 Cat schema 对 Pet 的 allOf 引用,重现针对 /pets 的 JSON PATCH 请求。跟踪 validator 如何解析 Pet 及其继承的 pet_type 属性,然后确定该请求是否被接受,或者验证为何拒绝该请求。issue 中没有指定项目文件或测试。
由索引模型根据 Issue 内容生成。
描述
Hi, I'm having issues getting an example spec using allOf to work. This is the spec, as provided by the OpenAPI docs:
openapi: 3.0.0
info:
title: AllOf.v1
version: '1.0'
servers:
- url: 'http://localhost:3000'
paths:
/pets:
patch:
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
discriminator:
propertyName: pet_type
responses:
'200':
description: Updated
components:
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
Dog: # "Dog" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Dog`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: boolean
breed:
type: string
enum: [ Dingo, Husky, Retriever, Shepherd ]
Cat: # "Cat" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Cat`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
hunts:
type: boolean
age:
type: integer
My test attempts to send a JSON PATCH request to the /pets endpoint, using:
[
'pet_type' => 'Cat',
'age' => 3,
'hunts' => true,
]
However, this only results in:
Request body did not match provided JSON schema.
Digging in a bit more, it appears that the validator doesn't see the pet_type property it should be inheriting from the Pet component.
Any experience with this, or ideas? Thanks in advance.
- 主要语言
- PHP
- 星标
- 500
- 派生
- 99
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cebe/php-openapi 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
cebe/php-openapi#250 ·
-
BC break in 1.8 未关闭
难度 5/5 一周以上 新手友好度 25/100
cebe/php-openapi#247 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 58/100
cebe/php-openapi#245 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 52/100
cebe/php-openapi#242 · 6 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 55/100
cebe/php-openapi#238 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
doctrine/collections#554 · 1 个 reaction ·
-
documentation
难度 2/5 1-2 天 新手友好度 72/100
components-web-app/docs#97 ·
-
难度 1/5 1-3 小时 新手友好度 88/100
WordPress/Documentation-Issue-Tracker#2513 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
bagisto/b2b-ecommerce#55 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
octobercms/october#6132 ·