@nha that’s a bug, should produce something like :x-oneOf
~like spec-tools does (https://github.com/metosin/spec-tools/blob/master/src/spec_tools/swagger/core.cljc#L19-L23). Would you like to do a PR?
Plan has been to move the Schema->JSON Schema conversion to Schema Tools at some point, and add the support for OpenAPI 3. Schema-tools & Spec-tools would do same stuff, and ring-swagger would be just a lite proxy in front. Contributions welcome.
Ok good to know it’s a known bug 🙂 I can try to make a PR yes (in my limited free time however - we don’t use swagger at work)
and then once it produces :x-oneOf
- there should be a definiton for this somewhere else?
(edit: I can probably find out just by generating a json with metosin/spec-tools)
also - thanks for making these! 🙂
was watching Rango yesterday and noticed this perfect illustration of proper swagger.
@nha thanks! spec-tools has some best-guess samples (https://github.com/metosin/spec-tools/blob/master/test/cljc/spec_tools/swagger/core_test.cljc#L15-L137) that can be used. Not 100% sure they are correct, so please fix if you find something odd - or just something working differently for Schema/Spec.
It seems that not all Schema mappings are verified with the JSON Schema Validator, would be good to have those. Would have caught the :oneOf
error…
I am not sure how to read that, but http://swagger.io/v2/schema.json# has a oneOf
property.
(I noticed just now as well the x-
prefix is defined there)
Also https://github.com/metosin/ring-swagger/pull/129 @ikitommi
Although I can’t think of a good match for anyOf
and allOf
using schemas
Side question - is there an OpenAPI 3 planned for ring-swagger
? If yes, will it be spec
-only or also support plumatic schema
?
(my primary interest here is about generating clients
Is the there a list of changes between 2 and 3 somewhere?
Spec / Schema part is mostly about converting Spec or Schema to JSON Schema and I doubt that has changed much, if at all
Hmm, JSON-Schema uses oneOf
OpenAPI v2 doesn't mention this and v3 does use oneOf
for some cases, outside of JSON-Schema
Swagger2 JSON Schema is defined using oneOf, but does not support it: https://github.com/OAI/OpenAPI-Specification/issues/57
OpenApi3 support would be awesome, here's the issue: https://github.com/metosin/ring-swagger/issues/121
travis build failed - looks unrelated to the code changes though
No command 'lein2' found, did you mean:
Should be fixed in master
ah you were faster - thanks 🙂 - I’ll rebase
doh - did not realize you were using midje - I’ll need to make the test actually pass 😛
Alright - updated the pr and it passes validation - I am not sure however what is the purpose of "void"
almost a changelog 😛 https://github.com/OAI/OpenAPI-Specification/issues/333#issuecomment-283752631 the summary from this discussion: - swagger is a subset of json schema, and up until version 2 did not have oneOf, anyOf, allOf. I think for this version we should use x-oneOf x-anyOf - version 3 supports it so hopefully this will not be a question anymore when implementing openapi 3