9

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 Answer 1

9

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.