Swagger 编辑器显示路径参数的“架构错误:不应具有附加属性"错误 [英] Swagger Editor shows the “Schema error: should NOT have additional properties” error for a path parameter

查看:37
本文介绍了Swagger 编辑器显示路径参数的“架构错误:不应具有附加属性"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 OpenAPI (Swagger) 定义并在 http://editor.swagger.io.出于某种原因,Swagger 编辑器显示此错误:

I am creating an OpenAPI (Swagger) definition and checking its validity in http://editor.swagger.io. For some reason, Swagger Editor shows this error:

Schema error at paths['/some-endpoint/{id}/name-and-address'].get.parameters[0]
should NOT have additional properties
additionalProperty: type, allowEmptyValue, enum, name, in, description, required
Jump to line 142

以下是我的 YAML 文件:

Below is my YAML file:

paths:
  '/some-endpoint/{id}/name-and-address':
    get:
      tags:
        - InvolvedParty
      summary: Retrieve basic information about...
      operationId: getNameAndAddressUsingGET
      produces:
        - '*/*'
      parameters:
        - name: id
          in: path
          description: The unique identification
          required: true
          type: string
          allowEmptyValue: false
          enum:
            - '@coderange[1'
            - 'infinity]'
      responses:
        '200':
          description: Success

正如错误消息所暗示的那样,我没有添加任何其他属性.如何修复此错误?

I haven't added any other properties as the error message implies. How to fix this error?

推荐答案

删除 allowEmptyValue - 它仅用于查询和 formData 参数,而不用于路径参数.

Remove allowEmptyValue - it's only used with query and formData parameters, but not with path parameters.

这篇关于Swagger 编辑器显示路径参数的“架构错误:不应具有附加属性"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆