如何重用招摇定义并删除其中的某些参数? [英] How to reuse swagger definitions and remove some of the parameters in it?
本文介绍了如何重用招摇定义并删除其中的某些参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
definitions:
User:
type: object
properties:
id:
type: integer
username:
type: string
first_name:
type: string
last_name:
type: string
password:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
required:
- username
- first_name
- last_name
- password
/api/users:
post:
description: Add a new user
operationId: store
parameters:
- name: user
description: User object
in: body
required: true
type: string
schema:
$ref: '#/definitions/User'
produces:
- application/json
responses:
"200":
description: Success
properties:
success:
type: boolean
data:
$ref: '#/definitions/User'
如您所见,在/api/users
下的post键中,我将User
定义用作其模式.
As you can see, in the post key under /api/users
I used the User
definition as my schema on it.
我想减少代码,所以我将User
定义重用为自己的架构.这里的问题是我不需要id
,created_at
和updated_at
字段.
I want to lessen my code so I reused the User
definition as my schema. The problem here is that I do not need the id
, created_at
and updated_at
fields.
除了提到的字段之外,是否有一种方法可以继承某些字段?另外,由于我想学习敏捷,所以我希望提出一些建议以使它更好.谢谢.
Is there a way to just inherit some of the fields except the fields mentioned? Also, I would love some suggestions to make it better since I'm trying to learn swagger. Thank you.
推荐答案
查看全文