swagger-api / validator-badge

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

swagger ui validation errors with security definitions #73

Closed deefactorial closed 8 years ago

deefactorial commented 8 years ago

I posted this issue on swagger-tools: https://github.com/apigee-127/swagger-tools/issues/329

When I run the swagger-tools UI and I browse to the /docs There is an ERROR at the bottom of the page,

When I click on it brings me to:

https://online.swagger.io/validator/debug?url=https://cloud.openmoney.cc/api-docs

The errors I'm getting are:

{"schemaValidationMessages":[{"level":"error","domain":"validation","keyword":"oneOf","message":"instance failed to match exactly one schema (matched 0 out of 6)","schema":{"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/securityDefinitions/additionalProperties"},"instance":{"pointer":"/securityDefinitions/oauth2AccessCodeSecurity"}},{"level":"error","domain":"validation","keyword":"oneOf","message":"instance failed to match exactly one schema (matched 0 out of 6)","schema":{"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/securityDefinitions/additionalProperties"},"instance":{"pointer":"/securityDefinitions/oauth2ApplicationSecurity"}},{"level":"error","domain":"validation","keyword":"oneOf","message":"instance failed to match exactly one schema (matched 0 out of 6)","schema":{"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/securityDefinitions/additionalProperties"},"instance":{"pointer":"/securityDefinitions/oauth2ImplicitSecurity"}},{"level":"error","domain":"validation","keyword":"oneOf","message":"instance failed to match exactly one schema (matched 0 out of 6)","schema":{"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/securityDefinitions/additionalProperties"},"instance":{"pointer":"/securityDefinitions/oauth2PasswordSecurity"}}]}

My swagger.json file has no errors on http://editor.swagger.io/

webron commented 8 years ago

Haven't tested it, but I would guess that it's because your URLs (or rather URIs) are invalid URLs (due to the curly braces). If you can test easily, try removing them and see if it resolves the issue. Otherwise, I could get around to testing it a bit later.

webron commented 8 years ago

Okay, just tested it, and that's indeed the issue. The URLs for oauth2 definitions do not allow templating/parameter substitution like regular paths. You could escape the curly braces, but it would still not provide you with what you hope - templated URLs.

If you'd like to see supported added for it in the future, I'd suggest opening an issue on the spec.

I'm afraid this is not really a bug, so will be closing the issue.