Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty parameters array in swagger 2.0 spec yields a validation error #395

Closed
who opened this issue Apr 10, 2015 · 10 comments
Closed

Empty parameters array in swagger 2.0 spec yields a validation error #395

who opened this issue Apr 10, 2015 · 10 comments

Comments

@who
Copy link

who commented Apr 10, 2015

If you have a HTTP GET path defined with an empty parameters array, the built-in validator will complain.

Here's a yaml block you can use for repro:

swagger: '2.0'
info:
  version: "0.0.0"
  title: "My bug repro API"
paths:
  /persons:
    get:
      # Describe this verb here. Note: you can use markdown
      description: |
        Gets `Person` objects.
        Optional query param of **size** determines
        size of returned array
      # This is an empty parameters array
      parameters: []
      responses:
        200:
          description: Successful response
          schema:
            title: ArrayOfPersons
            type: array
            items:
              title: Person
              type: object
              properties:
                name:
                  type: string
                single:
                  type: boolean

The validator message contains this:

Array is too short (0), minimum 1
code: "ARRAY_LENGTH_SHORT"
message: "Array is too short (0), minimum 1"
path: Array [4]
0: "paths"
1: "/persons"
2: "get"
3: "parameters"
description: "The parameters needed to send a valid API call."
level: 900

It appears this issue is similar to swagger-api/validator-badge#11

@who
Copy link
Author

who commented Apr 10, 2015

After further digging, this is a bug surfaced from the swagger 2.0 spec as it is defined by apigee-127/swagger-tools.

@mohsen1
Copy link
Contributor

mohsen1 commented Apr 10, 2015

The schema has updated to fix this issue. It will get resolved when we update to the latest swagger-tools which has latest schema.

@mohsen1
Copy link
Contributor

mohsen1 commented Apr 10, 2015

@whitlockjc I thought you updated the schema in swagger-tools already. Please open a ticket in swagger-tools for updating the schema in the next release and link it to this issue if it's not the case

@whitlockjc
Copy link
Contributor

I did not, I've not put any time to swagger-tools due to other projects. I'll get it fixed tomorrow.

@who
Copy link
Author

who commented Apr 14, 2015

@mohsen1

It looks like swagger-tools has updated the schema.

@mohsen1
Copy link
Contributor

mohsen1 commented Apr 14, 2015

@who it's not published yet. @whitlockjc

@mohsen1
Copy link
Contributor

mohsen1 commented Apr 22, 2015

Fix for this is deployed now.

@mohsen1 mohsen1 closed this as completed Apr 22, 2015
@who
Copy link
Author

who commented Apr 22, 2015

🤘 Thank you!

@ayushidalmia
Copy link

@webron
Copy link
Contributor

webron commented Aug 23, 2016

That has nothing to do with the topic of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants