Swagger为什么将GET请求标记为重复映射?

时间:2019-06-03 12:01:46

标签: rest api http swagger openapi

我有这2个GET请求,一个是/report,另一个是/report/{id}

paths:
  /report:
    get:
      operationId: getReportsList
      responses:
        '200':
          description: List of reports
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Metadata'
    get:
      operationId: getReportById
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Report is finished and returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Report'

SwaggerHub针对第二个GET显示了错误,并带有说明

  

重复的映射键

您能告诉我我在做什么错吗?为什么Swagger认为带有和不带有路径变量的URL都是相同的?

1 个答案:

答案 0 :(得分:1)

添加新路径,在其中明确为第二个<!DOCTYPE html> <html> <head> <title>Table Test</title> </head> <body> <table> <tr> <td> <p> First row </p> </td> </tr> <tr> <td> <p> Second row jygq </p> </td> </tr> </table> </body> </html>附加路径变量/report/{id}