首页 > 解决方案 > “=”在 Swagger 路径参数中是什么意思?

问题描述

=以下 OpenApi / Swagger 规范的路径参数中的“”是什么意思?

https://github.com/grafeas/grafeas/blob/master/proto/v1beta1/swagger/grafeas.swagger.json#L18

这是一段摘录(为了便于阅读,从 JSON 转换为 YAML):

swagger: '2.0'
info:
  title: grafeas.proto
  version: version not set
schemes:
  - http
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  '/v1beta1/{name=projects/*/notes/*}':
    get:
      summary: Gets the specified note.
      operationId: GetNote
      responses:
        '200':
          description: A successful response.
          schema:
            $ref: '#/definitions/v1beta1Note'
      parameters:
        - name: name
          description: |-
            The name of the note in the form of
            `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
          in: path
          required: true
          type: string
      tags:
        - GrafeasV1Beta1

路径定义为/v1beta1/{name=projects/*/notes/*}并定义了一个名为的参数name,但是当我将整个.json放入https://editor.swagger.io时,我得到以下形式的错误:

声明的路径参数“name=projects/*/notes/*”需要在路径或操作级别定义为路径参数

标签: swaggeropenapigrafeas

解决方案


我相信这个招摇规范是自动生成的,并且=TEXT{param}块内是一个错误。我已将此作为https://github.com/grafeas/grafeas/issues/379提出。


推荐阅读