swagger-api / validator-badge

Validate your Swagger JSON/YAML today!
http://swagger.io
Apache License 2.0
210 stars 85 forks source link

Operation parameters array with minItems can cause a 500 Internal Error #51

Closed tavantzo closed 9 years ago

tavantzo commented 9 years ago

Hi,

according to the swagger specification the parameter object can have defined minItems but when I'm using it, the swagger editor, through the swaggerhub at least, badge turns to red (ERROR) while the swagger validate says that the document contains no errors.

Of course this is a minor issue but it can cause a headache at someone as it gave at me.

Remote Address:52.0.196.189:443
Request URL:https://validator.swaggerhub.com/debug
Request Method:POST
Status Code:500 Internal Server Error
Response Headers
view source
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, DELETE, PUT
Access-Control-Allow-Origin:*
Cache-Control:must-revalidate,no-cache,no-store
Connection:keep-alive
Content-Length:323
Content-Type:text/html; charset=ISO-8859-1

{
    "swagger": "2.0",
    "info": {
        "version": "throwable",
        "title": "TavaPay",
        "description": "TavaPay Draft"
    },
    "paths": {
        "/test/{id}": {
            "post": {
                "description": "Success",
                "parameters": [
                    {
                        "name": "id",
                        "type": "string",
                        "in": "path",
                        "required": true
                    },
                    {
                        "name": "foo",
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "required": true,
                        "minItems": 0,
                        "in": "formData"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok"
                    }
                }
            }
        }
    }
}

This is the document to reproduce that error in swaggerhub

swagger: '2.0'
info:
  version: throwable
  title: TavaPay
  description: TavaPay Draft
paths:
  '/test/{id}':
    post:
      description: Success
      parameters:
        - name: id
          type: string
          in: path
          required: true
        - name: foo
          type: array
          items:
            type: string
          required: true
          minItems: 0
          in: formData
      responses:
        '200':
          description: ok
webron commented 9 years ago

Thanks for opening the ticket. Apparently, there's a bug with the version of the json schema validator that use, and the fix is as simple as upgrading it. We'll push this fix to production soon.

webron commented 9 years ago

Deployed to the relevant environments.