每个路径和方法所需的属性

时间:2017-08-08 16:49:29

标签: swagger swagger-2.0 openapi

请考虑以下示例规范:

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

fieldBPOST方法都需要PATCH属性。是否有可能只需要单个路径和方法,而不必指定两个不同的模型定义?

如果没有,那么实现这一目标的好方法是什么?

0 个答案:

没有答案