swagger-api / validator-badge

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

HTTP 500: Problem accessing /validator/debug #14

Closed vpavlushkov closed 9 years ago

vpavlushkov commented 9 years ago

Hi, I have setup Swagger UI server instance which is to display the JSON spec in a more readable format. The page opens fine and the JSON file https://dox.cabforce.com/swagger_v2.json is available when entering this URL in a browser. However, the validator icon is red and the only thing that I can see by following the link http://online.swagger.io/validator/debug?url=https://dox.cabforce.com/swagger_v2.json is the following:

HTTP ERROR 500: Problem accessing /validator/debug. Reason: Internal Server Error

Powered by Jetty://

Note that the JSON file in question is parsed successfully when uploaded to editor.swagger.io. At the same time, I see that http://petstore.swagger.io/v2/swagger.json validates with a known issue of having empty array.

Would it be possible to get a bit more info what is going on on validator side and what exactly is making it to return me the red icon? Thank you! Would it be possible to get

fehguy commented 9 years ago

Howdy, It appears that your example objects are causing the validator to explode. This is a legitimate bug in the validator logic. If you can help look into that issue specifically, that'd be a huge help. Or you can disable your examples and the validator should lose it's ugly green.

vpavlushkov commented 9 years ago

Sure thing! I am using single-valued examples as a property of a field and multi-valued examples as a property of an object/schema. I will play a bit to see which of them causes the problem. Victor

fehguy commented 9 years ago

thanks. we will fix it, but that will keep you going. You can stuff it in a string too. My guess is the model example is causing the explosion.

vpavlushkov commented 9 years ago

Here is what I have found. Just as you have expected, the trouble-makers were the model examples of the /definitions section when all the values are written combined, like that:

        "Amount": {
            "required": [
                "currency",
                "exchangeRate",
                "net",
                "netNumber",
                "tax",
                "taxNumber",
                "total",
                "totalNumber"
            ],
            "properties": {
                "currency": {
                    "description": "Currency",
                    "type": "string"
                },
                "exchangeRate": {
                    "type": "number",
                    "format": "float"
                },
                "net": {
                    "type": "string",
                    "format": "currency"
                },
                "netNumber": {
                    "type": "number",
                    "format": "float"
                },
                "tax": {
                    "type": "string"
                },
                "taxNumber": {
                    "type": "number",
                    "format": "float"
                },
                "total": {
                    "type": "string"
                },
                "totalNumber": {
                    "type": "number",
                    "format": "float"
                }
            },
            "example": {
                "currency": "EUR",
                "exchangeRate": 1,
                "net": "235,26",
                "netNumber": 235.26,
                "tax": "11,76",
                "taxNumber": 11.76,
                "total": "247,02",
                "totalNumber": 247.02
            }
        }

When the model was rewritten to have example field next to each property, the validator turned green:

        "Amount": {
            "required": [
                "currency",
                "exchangeRate",
                "net",
                "netNumber",
                "tax",
                "taxNumber",
                "total",
                "totalNumber"
            ],
            "properties": {
                "currency": {
                    "description": "Currency",
                    "type": "string",
                    "example": "EUR"
                },
                "exchangeRate": {
                    "type": "number",
                    "format": "float",
                    "example": 1
                },
                "net": {
                    "type": "string",
                    "format": "currency",
                    "example": "235,26"
                },
                "netNumber": {
                    "type": "number",
                    "format": "float",
                    "example": 235.26
                },
                "tax": {
                    "type": "string",
                    "example": "11,76"
                },
                "taxNumber": {
                    "type": "number",
                    "format": "float",
                    "example": 11.76
                },
                "total": {
                    "type": "string",
                    "example": "247,02"
                },
                "totalNumber": {
                    "type": "number",
                    "format": "float",
                    "example": 247.02
                }
            }
        },

That is really a minor glitch in the validator and I will simply stick to the latter format of example documentation. Thanks for your help!

However, it would be really nice to get in debug mode also the exceptions when the validator throws HTTP 500. Even though it is difficult to judge without the code what is the reason for the exception but at least knowing where to look is valuable. Otherwise, the guys like me are clueless what possibly went wrong and we have to bother you asking to check. ;-)