Swagger:Issue with Path parameter

情到浓时终转凉″ 提交于 2019-11-29 00:58:57

Basically, you're declaring a path that has a path parameter in it, by using path templates. In this case {id} declares a path parameter called id.

When you declare such a path, it means that you have to declare that path parameter as part of the operation.

Take a look at this YAML example:

  /pets/{id}:
    get:
      description: Returns a user based on a single ID, if the user does not have access to the pet
      operationId: findPetById
      produces:
        - application/json
        - application/xml
        - text/xml
        - text/html
      parameters:
        - name: id
          in: path
          description: ID of pet to fetch
          required: true
          type: integer
          format: int64
      responses:
        '200':
          description: pet response
          schema:
            $ref: '#/definitions/pet'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/errorModel'

You can see there's an {id} in the path, and a corresponding id parameter definition. Without it, the spec won't be valid.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!