0

使用路径参数petId作为id请求正文中的字段值。我们该怎么做?

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets/{petId}:
    put:
      summary: Info for a specific pet
      operationId: UpdatePetInfoById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          schema:
            type: string
      requestBody:
          description: Info about a new pet
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
      responses:
        '200':
          description: Expected response to a valid request
components:
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id: _{$request.path.petId}_
        name:
          type: string
        tag:
          type: string
4

0 回答 0