如何从 OpenAPI 3.0 中的数组模式引用另一个模式?
How to reference another schema from an array schema in OpenAPI 3.0?
我有一个 OpenAPI 3.0 模式,其中一个属性(taskRequireSkills
数组)需要引用另一个模式(TaskRequireUserSkill
),如下所示:
components:
schemas:
Task:
properties:
id:
type: integer
name:
type: string
taskRequireSkills:
type: array
schema: # ERROR : bad indentation of a mapping entry
$ref: '#/components/schemas/TaskRequireUserSkill'
created_at:
type: string
format: datetime
TaskRequireUserSkill:
properties:
id:
type: integer
skill_id:
type: integer
skill_name:
type: string
ordering:
type: integer
created_at:
type: string
format: datetime
但我收到 "bad indentation of a mapping entry" 错误。
我想我的语法无效。
但哪种语法有效?
$refs 数组定义如下:
taskRequireSkills:
type: array
items:
$ref: '#/components/schemas/TaskRequireUserSkill'
我有一个 OpenAPI 3.0 模式,其中一个属性(taskRequireSkills
数组)需要引用另一个模式(TaskRequireUserSkill
),如下所示:
components:
schemas:
Task:
properties:
id:
type: integer
name:
type: string
taskRequireSkills:
type: array
schema: # ERROR : bad indentation of a mapping entry
$ref: '#/components/schemas/TaskRequireUserSkill'
created_at:
type: string
format: datetime
TaskRequireUserSkill:
properties:
id:
type: integer
skill_id:
type: integer
skill_name:
type: string
ordering:
type: integer
created_at:
type: string
format: datetime
但我收到 "bad indentation of a mapping entry" 错误。 我想我的语法无效。 但哪种语法有效?
$refs 数组定义如下:
taskRequireSkills:
type: array
items:
$ref: '#/components/schemas/TaskRequireUserSkill'