Swagger parameter error “is not exactly one from <#/definitions/parameter>”?

此生再无相见时 提交于 2019-12-12 10:34:02

问题


I'm trying to write a simple Swagger / Open API definition using the Swagger Editor.

swagger: "2.0"

info:
  version: 1.0.0
  title: Test API
  description: Test API

schemes:
  - https
host: hipaa.ai
basePath: /v1

paths:
  /comments:
    post:
      summary: Your comments
      description: Comments
      parameters:
      - name: text
        in: body
        description: An array of text strings
        type: array
        minItems: 1
        maxItems: 1000
        items:
          type: text

I'm getting the following error:

Schema error at paths./comments.post.parameters[0]
is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>

I've checked the Swagger schema reference, and the petstore example, but I'm not sure why I'm getting this. Any ideas?


回答1:


Body parameters use the schema keyword to specify the type, so you need to move type, items, minItems and maxItems under schema.

Also, type: text is not a valid type. Use type: string instead.

      parameters:
      - name: text
        in: body
        description: An array of text strings
        schema:
          type: array
          minItems: 1
          maxItems: 1000
          items:
            type: string


来源:https://stackoverflow.com/questions/43592634/swagger-parameter-error-is-not-exactly-one-from-definitions-parameter

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