swagger-cli icon indicating copy to clipboard operation
swagger-cli copied to clipboard

Duplicate properties not detected by validate

Open gmuloc opened this issue 7 years ago • 0 comments

Hello,

I have found what I think may be an issue where the validation of the json is accepted but swagger-ui will detect an duplicate-key error

Platform:

  • OSX
  • swagger-cli version 2.2.1
# swagger-cli validate swagger_incorrect.json                                                                                                                                                                      
swagger_incorrect.json is valid

This is my file with duplicate keys in definitions (I have stripped down a lot of the file where the issue appeared and even removed the paths using the definition.

{
    "swagger": "2.0",
    "info": {
      "title": "blah",
      "version": "2018-05-07"
    },
    "paths": {
    },
    "definitions": {
      "data-post": {
        "type": "object",
        "properties": {
          "blah": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "dup_prop": {
                  "type": "string"
                },
                "dup_prop": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }

Loading this in swagger-ui gives me the error (can add screenshot if needed):

Errors
 
Parser error on line 23
duplicated mapping key

According to my understanding/reading of the OpenAPI / Swagger specification this is indeed invalid. Let me know if more information is needed.

gmuloc avatar Feb 21 '19 11:02 gmuloc