问题描述
deFinitions:
Pet:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
age:
type: integer
还有一个用于获取单个宠物的 /pet/{id}
GET 方法:
paths:
/pet/{id}:
get:
produces:
- application/json
parameters:
- name: id
in: path
required: true
type: string
format: uuid
responses:
200:
description: Ok
schema:
$ref: '#/deFinitions/Pet'
现在我想添加 /pet
POST 方法来添加新宠物,如下所示:
paths:
/pet
post:
consumes:
- application/json
produces:
- application/json
parameters:
- name: pet
in: body
required: true
schema:
$ref: '#/deFinitions/Pet' # <-- issue line
responses:
200:
description: Ok
schema:
$ref: '#/deFinitions/Pet'
问题出在参数的 schema
上,因为 id
是由服务器生成的,我不想在请求正文中提供它。然而,实际的 Pet
定义非常复杂,在没有 id
属性的情况下在多个地方重复它会很愚蠢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)