我在组件 --> 架构中有以下 OpenAPI。在 CreateBookDto 中,我只想引用我的 Person 架构的
id
属性。这可以通过 OpenAPI 实现吗?如果是,怎么办?如果没有,这个功能有什么原因不存在吗?
Person:
type: object
properties:
id:
type: number
description: ID of the person
username:
type: string
description: Username of the person
books:
description: All books of one person
type: array
items:
$ref: '#/components/schemas/Book'
CreateBookDto:
type: object
properties:
title:
type: string
description: The title of the book
person_id: <-- Here I want to reference to the id property of Person
type: number
description: The ID of the person
您可以使用 JSON 指针
...
person_id:
$ref: '#/components/schemas/Person/properties/id'
...