swagger-api / validator-badge

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

Validator fails when definitions don't have "properties" attribute #71

Closed dsikkema-magento closed 8 years ago

dsikkema-magento commented 8 years ago

Here's the json: http://devdocs.magento.com/swagger/schemas/2.0.0-rc-api-schema.json

Here is an example of the section that is causing the validator badge to fail (nested under the "definitions" object):

"store-data-store-extension-interface" : {
  "type" : "object",
  "description" : "ExtensionInterface class for @see \\Magento\\Store\\Api\\Data\\StoreInterface"
}

I'm getting a lot of messages in the response of the form:

["attribute definitions.store-data-store-extension-interface.properties is missing"

But when I use the schema found here, https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json, and validate locally using https://github.com/justinrainbow/json-schema, the validation is successful. And from doing my best to read the swagger schema myself, I cannot see anything which requires a definition object to have a properties attribute.

So here's my question - is the validator badge producing results that disagree with the schema? If not, does that mean the schema requires all definition objects to have a properties object? If so, then why when using the same schema I find that my json is valid, in disagreement with the validator badge?

Thanks!

webron commented 8 years ago

This is a duplicate of #69 which is actually based on https://github.com/swagger-api/swagger-parser/pull/165.

dsikkema-magento commented 8 years ago

@webron this isn't a bug report, but a question. How does the parser affect the validator badge? But that's not my main question -- is it true that the JSON is valid, according to the open api schema? And so I don't need to worry about that particular failure?

dsikkema-magento commented 8 years ago

And when that pull request gets accepted, does it mean the validator will start to work immediately, or after some time, or must clients do something specific to make the validator work?

fehguy commented 8 years ago

Hi @dsikkema the parser actually does all the work. The messages that it produces are simply output by the validator badge web service, so as soon as a change is made in the parser AND the dependency is updated in the validator project, yes it'll take effect immediately.

dsikkema-magento commented 8 years ago

Thank you! So if the badge is supposed to only do validation, can I suggest using an existing, general purpose schema validator to compare the json against the schema? That would guarantee agreement between the validator badge and the schema, right?

fehguy commented 8 years ago

Yes, you have a couple options.

1) If you're looking at doing just a schema validation, you can use any of a number of schema validation projects, including some lighter-weight ones in node.js

2) You can call our online validator from your CI build. There is an option to POST the spec to it, and it'll return back whether it's valid or not

3) If you're brave, you can spin up a docker instance of the online validator from https://hub.docker.com/r/swaggerapi/swagger-validator/ and call it from your jenkins build. That's probably the most reliable way to do so