swagger-api / validator-badge

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

This valid JSON causes a 500 error #48

Closed MichaelJCole closed 8 years ago

MichaelJCole commented 9 years ago

Hi, this valid JSON causes a 500 error in the validator. Thanks!

{
  "swagger": "2.0",
  "info": {
    "title": "test API",
    "description": "test Swagger 2.0 API specification.  This API spec can be used for integrating your Form.io project into non-HTML5 programs like \"native\" phone apps, \"legacy\" and \"enterprise\" systems, embedded \"Internet of Things\" applications (IoT), and other programming languages.  Note: The URL's below are configured for your specific project and form.",
    "termsOfService": "http://form.io/terms/",
    "contact": {
      "name": "Form.io Support",
      "url": "http://help.form.io/",
      "email": "support@form.io"
    },
    "license": {
      "name": "MIT",
      "url": "http://opensource.org/licenses/MIT"
    },
    "version": "1.0.0"
  },
  "host": "api.localhost:3000",
  "basePath": "/project/55b09c8f111b3a0100ac8c20/form/55b0a219111b3a0100ac8c28",
  "schemes": [
    "http"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/project/55b09c8f111b3a0100ac8c20/form/55b0a219111b3a0100ac8c28/submission": {
      "get": {
        "tags": [
          "submission"
        ],
        "summary": "List multiple submission resources.",
        "description": "This operation allows you to list and search for submission resources provided query arguments.",
        "operationId": "getsubmissions",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Resource(s) found.  Returned as array.",
            "schema": {
              "$ref": "#/definitions/submissionList"
            }
          },
          "401": {
            "description": "Unauthorized."
          }
        },
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "description": "How many records to skip when listing. Used for pagination.",
            "required": false,
            "type": "integer",
            "default": 0
          },
          {
            "name": "limit",
            "in": "query",
            "description": "How many records to limit the output.",
            "required": false,
            "type": "integer",
            "default": 10
          },
          {
            "name": "count",
            "in": "query",
            "description": "Set to true to return the number of records instead of the documents.",
            "type": "boolean",
            "required": false,
            "default": false
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Which fields to sort the records on.",
            "type": "string",
            "required": false,
            "default": ""
          },
          {
            "name": "select",
            "in": "query",
            "description": "Select which fields will be returned by the query.",
            "type": "string",
            "required": false,
            "default": ""
          },
          {
            "name": "populate",
            "in": "query",
            "description": "Select which fields will be fully populated with the reference.",
            "type": "string",
            "required": false,
            "default": ""
          }
        ]
      },
      "post": {
        "tags": [
          "submission"
        ],
        "summary": "Create a new submission",
        "description": "Create a new submission",
        "operationId": "createsubmission",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "security": [],
        "responses": {
          "201": {
            "description": "The resource has been created."
          },
          "400": {
            "description": "An error has occured trying to create the resource."
          },
          "401": {
            "description": "Unauthorized.  Note that anonymous submissions are *enabled* by default."
          }
        },
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Data used to create a new submission",
            "required": true,
            "schema": {
              "$ref": "#/definitions/submission"
            }
          }
        ]
      }
    },
    "/project/55b09c8f111b3a0100ac8c20/form/55b0a219111b3a0100ac8c28/submission/{submissionId}": {
      "get": {
        "tags": [
          "submission"
        ],
        "summary": "Return a specific submission instance.",
        "description": "Return a specific submission instance.",
        "operationId": "getsubmission",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Resource found",
            "schema": {
              "$ref": "#/definitions/submission"
            }
          },
          "401": {
            "description": "Unauthorized."
          },
          "404": {
            "description": "Resource not found"
          },
          "500": {
            "description": "An error has occurred."
          }
        },
        "parameters": [
          {
            "name": "submissionId",
            "in": "path",
            "description": "The ID of the submission that will be retrieved.",
            "required": true,
            "type": "string"
          }
        ]
      },
      "put": {
        "tags": [
          "submission"
        ],
        "summary": "Update a specific submission instance.",
        "description": "Update a specific submission instance.",
        "operationId": "updatesubmission",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Resource updated",
            "schema": {
              "$ref": "#/definitions/submission"
            }
          },
          "400": {
            "description": "Resource could not be updated."
          },
          "401": {
            "description": "Unauthorized."
          },
          "404": {
            "description": "Resource not found"
          },
          "500": {
            "description": "An error has occurred."
          }
        },
        "parameters": [
          {
            "name": "submissionId",
            "in": "path",
            "description": "The ID of the submission that will be updated.",
            "required": true,
            "type": "string"
          },
          {
            "in": "body",
            "name": "body",
            "description": "Data used to update submission",
            "required": true,
            "schema": {
              "$ref": "#/definitions/submission"
            }
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "type": "array",
            "items": {
              "properties": {
                "type": {
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "created": {
                  "type": "string",
                  "format": "date",
                  "description": "The date this resource was created."
                },
                "modified": {
                  "type": "string",
                  "format": "date",
                  "description": "The date this resource was modified."
                }
              }
            }
          },
          {
            "type": "string",
            "format": "date",
            "description": "The date this resource was created."
          },
          {
            "type": "string",
            "format": "date",
            "description": "The date this resource was modified."
          }
        ]
      },
      "delete": {
        "tags": [
          "submission"
        ],
        "summary": "Delete a specific submission",
        "description": "Delete a specific submission",
        "operationId": "deletesubmission",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "responses": {
          "204": {
            "description": "Resource was deleted"
          },
          "400": {
            "description": "Resource could not be deleted."
          },
          "401": {
            "description": "Unauthorized."
          },
          "404": {
            "description": "Resource not found"
          },
          "500": {
            "description": "An error has occurred."
          }
        },
        "parameters": [
          {
            "name": "submissionId",
            "in": "path",
            "description": "The ID of the submission that will be deleted.",
            "required": true,
            "type": "string"
          }
        ]
      }
    }
  },
  "definitions": {
    "submission": {
      "properties": {
        "roles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "externalIds": {
          "type": "array",
          "items": {
            "properties": {
              "type": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "created": {
                "type": "string",
                "format": "date",
                "description": "The date this resource was created."
              },
              "modified": {
                "type": "string",
                "format": "date",
                "description": "The date this resource was modified."
              }
            }
          }
        },
        "created": {
          "type": "string",
          "format": "date",
          "description": "The date this resource was created."
        },
        "modified": {
          "type": "string",
          "format": "date",
          "description": "The date this resource was modified."
        }
      }
    },
    "submissionList": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/submission"
      }
    }
  },
  "securityDefinitions": {
    "bearer": {
      "type": "apiKey",
      "name": "Authorization",
      "in": "header"
    }
  }
}
webron commented 9 years ago

Can you describe the steps you follow to reproduce it?

Do you host your definition in localhost? Open swagger-ui locally? Test the validator directly?

MichaelJCole commented 9 years ago

Hey webron, I put it into a pastebin and validated online.

http://pastebin.com/raw.php?i=vrmCEG0a

http://online.swagger.io/validator/debug?url=http://pastebin.com/raw.php?i=vrmCEG0a

http://online.swagger.io/validator?url=http://pastebin.com/raw.php?i=vrmCEG0a

I was working through errors and after resolving the last one, got the 500 error.

MichaelJCole commented 9 years ago

Hi webron, I think there are some serious problems with the parameters on PUT /path/{submission}

webron commented 9 years ago

There is. There are a few parameters there that have no name, and not in property.

MichaelJCole commented 9 years ago

Yes, for sure. That's a bug in my JSON. But the 500 error is a bug in the validator.

webron commented 9 years ago

Yup.

fehguy commented 8 years ago

See here:

http://online.swagger.io/validator/debug?url=http://pastebin.com/raw.php?i=vrmCEG0a

Looks like you're missing some in parameters.