简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM