请考虑以下示例规范:
swagger: '2.0'
info:
title: stackoverflow question
version: '1.0'
paths:
/websites:
post:
parameters:
- in: body
name: website
required: true
schema:
$ref: '#/definitions/website'
responses:
201:
description: Website created
/websites/{id}:
patch:
parameters:
- name: 'id'
in: 'path'
type: 'integer'
required: true
- in: body
name: fields
required: true
schema:
$ref: '#/definitions/website'
responses:
200:
description: Website updated
definitions:
website:
type: object
required:
- fieldB
properties:
fieldA:
type: string
readOnly: true
fieldB:
type: string
format: date-time
fieldC:
type: string
format: date-time
fieldB
和POST
方法都需要PATCH
属性。是否有可能只需要单个路径和方法,而不必指定两个不同的模型定义?
如果没有,那么实现这一目标的好方法是什么?