Yaml OpenAPI引用对象数组中对象的属性
我对Yaml中的OpenAPI规范有一个问题。我愿意创建一个id数组,其中包含另一个对象数组中每个对象的id。例如:Yaml OpenAPI引用对象数组中对象的属性,yaml,openapi,Yaml,Openapi,我对Yaml中的OpenAPI规范有一个问题。我愿意创建一个id数组,其中包含另一个对象数组中每个对象的id。例如: components: schemas: Author: type: object required: - id - name properties: id: type: string
components:
schemas:
Author:
type: object
required:
- id
- name
properties:
id:
type: string
name:
type: string
Books:
type: array
items:
type: string
$ref: '#/components/schemas/Books/items/properties/id' # the reference is not correct.
Books:
type: array
items:
type: object
$ref: '#/components/schemas/Book'
Book:
type: object
required:
- id
- title
properties:
id:
type: string
title:
type: string
如何正确指定它?您的意思是如何指示模式之间的逻辑关系?也就是说,表明StringsArray是一个用户ID数组,而不仅仅是随机ID?谢谢你的评论,我注意到我在定义模式时犯了一个错误,我纠正了它,并编写了一个更好的示例。我愿意指定模式之间的逻辑关系。在新的示例中,我有一个author,我希望他的书的所有id都位于一个数组中,该数组是schema author中的一个属性。