我正在构建一个 schema A
,它包含一个引用另一个 schema 的属性B
。我遇到的问题是,我只需要 schema 中枚举属性的一个子集B
。有没有办法在 yaml 文件中做到这一点?举个简单的例子,如果我正在为一家兽医办公室构建一些东西:
components:
schemas:
Dog:
properties:
color:
description: Color of the dog
$ref: "#/comonents/schema/color"
injury:
description: Information about the injury
$ref: "#/comonents/schema/InjuryInfo"
InjuryInfo:
properties:
location:
description: where on the animal is the injury
type: string
enum:
- Body
- Leg
- Wing
details:
description: Additional Details
type: string
otherProperty:
description: Some other property
type: string
我需要重用该InjuryInfo
架构,但我需要该Dog
架构仅允许属性InjuryInfo.location
和InjuryInfo.details
。并且Dog.injury.location
仅包含枚举值的子集。这可以从yaml文件中实现吗?