如何在 openapi 3.0.2 中格式化 DELETE 方法?

How to format a DELETE method in openapi 3.0.2?

我无法找到一种方法来为我刚刚在 API 设计中创建的 POST 方法创建 DELETE 方法。 post 接受 GlobalOrderSetupInfo 的 requestBody,在该对象中还有另一个对象,它将是我想将 GlobalOrderSetupInfo 信息添加到的不同会话的数组,在 delete 方法中我需要删除相同的信息但是你不能有一个带有 requestBody 的删除方法。我该如何着手创建它?

这是我的 post 方法:

'/api/globalorderdays':
post:
  tags:
    - Setup Global Order Days
  summary: Allows user to add orderdays to multiple sessions
  requestBody:
    required: true
    description: put text here
    content:
      application/json:
        schema:
          type: object
          items:
            $ref: '#/components/schemas/GlobalOrderSetupInfo'
  responses:
    '201':
      description: Created
    '400':
      description: Bad request
    '401':
      description: Unauthorized
components:
schemas:
GlobalOrderSetupInfo:
  description: 'Put Text Here'
  type: object
  properties:
    Id:
      type: integer
    AvailableHolidayList:
      type: string
    SelectedOrderHolidays:
      type: string
      example: "New Year's Day, President's Day, Memorial Day, Labor Day, Veterans Day, Thanksgiving Day, Chistmas Day"
    SelectedHolidays:
      type: string
      example: "New Year's Day, President's Day, Memorial Day, Labor Day, Veterans Day, Thanksgiving Day, Chistmas Day"
    OrderDays:
      type: string
      example: "01/01/2000"
    NoOrderDays:
      type: string
      example: "01/01/2000"
    AllSessionList:
      uniqueItems: false
      type: array
      items:
        $ref: '#/components/schemas/SessionInfoList'
    SessionIdString:
      type: string
      example: "15"

SessionInfoList:
  description: 'Put Text Here'
  type: object
  properties:
    Id:
      type: integer
    SessionID:
      type: integer
    Name:
      type: string
      example: "Harbor"
    Type:
      type: string
    GroupName:
      type: string
      example: "PHACTS"
    IsChecked:
      type: boolean
      default: false
      example: true/false
    SetupID:
      type: string

通常,您的 POST 方法会创建一个新实体,并且 returns 该实体的 ID。然后你可能有额外的路线来通过 ID 获取那个实体,更新(PATCH)它,或者删除它。

因此在您的示例中,DELETE 的条目可能如下所示:

'/api/globalorderdays/{id}':
  parameters:
    - in: path
      name: id
      required: true
      schema:
        type: integer
  get:
    summary: Get orderdays by id
    responses:
      '200':
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GlobalOrderSetupInfo'
  delete:
    summary: Delete orderdays by id
    responses:
      '204':
        description: Deleted
      '404':
        description: id not found
      '401':
        description: Unauthorized