Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

swagger

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?

like image 873
Allyl Isocyanate Avatar asked Apr 24 '17 15:04

Allyl Isocyanate


1 Answers

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
like image 171
Helen Avatar answered Oct 17 '22 01:10

Helen