Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the JSON schema version used in swagger to represent the models? #156

Closed
guillemdc opened this issue Oct 14, 2014 · 5 comments
Closed

Comments

@guillemdc
Copy link

I've been documenting my APIs with swagger and they worked flawlessly with swaggerUI and with codeGen, but now, based on the models specified in the swagger files I'm trying to validate the inputs in the server and the libraries I used, which validate JSON schema V4 don't work when I use $ref.

Could you please specify somewhere what's the JSON schema used and, if possible, what php libraries can be found to validate inputs against the schemas. I can't find that information anywhere :S.

Regards!

@webron
Copy link
Member

webron commented Oct 14, 2014

We don't use JSON Schema entirely but a sub-set of draft v4 to describe the models. There are some additional fields which are not included in the json schema specification (which may or may not cause validation to fail, depending on which validator you use).

It is described here - https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#schemaObject and the additional fields are here - https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#fixed-fields-13.

If you can share a model that fails validation, it may help me understand what the issue may be.

@guillemdc
Copy link
Author

Everything that includes a $ref passes the validation even when the stuff inside of the referenced model is broken in some way e.g. missing a required field.

I opened a ticket in the validation library github you may like to check since I've put there an example and the guy that developed it explains deeper how the model could look like in order to use automated validation:
geraintluff/jsv4-php#16

Anyway, if there's no tool to automate the validation of the swagger models, that would mean the creation of two different schemas, one in the swagger format and one in the official JSON schema one.

@webron
Copy link
Member

webron commented Oct 14, 2014

@guillemdc - @geraintluff has been offering us assistance with regards to the schema and such so he's familiar to an extent with Swagger.

I think I should have asked in the first place - which version of Swagger do you use? If it's 1.2, then the models there are nowhere near a valid json schema. If 2.0, then keep in mind the references you used in geraintluff/jsv4-php#16 are indeed wrong.

I'd really rather not span it across different repositories of different projects though, which is why I asked to see a sample model. So it's up to you where you want to continue the discussion - here or there.

@guillemdc
Copy link
Author

I'm using swagger 1.2, so I guess that's where the problem is. You can both close the discussion since the source of the issues is obviously that I'm using that version and it doesn't comply with the Json Schema 4.0.

Before closing this, I'll just bother you with one little off topic question, do you know when you'll update the petstore demo (http://petstore.swagger.wordnik.com/) to work with Swagger 2.0?

I know the new swagger specification is already released, but IMHO right now there's not so much information, examples and documentation in general to move there right now and I'd rather see it working before doing it.

Thank you very much for the support and the quick answers guys ;).

@fehguy
Copy link
Contributor

fehguy commented Oct 14, 2014

hi, a v2 swagger-ui is live, here:

http://petstore.swagger.wordnik.com/ui/

The default one will be replaced shortly after the UI is officially released

@webron webron closed this as completed Oct 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants