Subpaths in Swagger YAML declaration

若如初见. 提交于 2019-12-03 16:28:11

What you can do is declare the parameter at the top level, and then refer to it.

swagger: '2.0'
info:
  version: '0.0.1'
  title: Test API
host: api.test.com
basePath: /
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
parameters:
  partnerId:
    name: partnerId
    in: path
    type: integer
paths:
  /versions:
    post:
      responses:
        '201':
          description: Returns all versions.
        default:
          description: unexpected error
  /partners/{partnerId}/users/{userId}/sessions:
    parameters:
      - $ref: '#/parameters/partnerId'
      - name: userId
        in: path
        type: string
    post:
      responses:
        '201':
          description: Returns a UserSession object with info about the user session.
        default:
          description: unexpected error
  /partners/{partnerId}/books/{bookId}/:
    parameters:
      - $ref: '#/parameters/partnerId'
      - name: bookId
        in: path
        type: string
    get:
      responses:
        '200':
          description: Gets a book.
        default:
          description: unexpected error
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!