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

Support for either conditional and if #13

Closed
sebastiansen opened this issue Aug 21, 2014 · 3 comments
Closed

Support for either conditional and if #13

sebastiansen opened this issue Aug 21, 2014 · 3 comments

Comments

@sebastiansen
Copy link

I know this is not currently supported, but is there any workaround or future plans at the moment?

@Deraen
Copy link
Member

Deraen commented Aug 21, 2014

It's easy enough to add support for those (you can do this on your own project):

(defmethod ring.swagger.json-schema/json-type schema.core.ConditionalSchema [e]
    (->json (-> e :preds-and-schemas first second)))

Problem is that the JSON-Schema doesn't have way to describe those. This implementation uses the first schema for the description. This is pretty much the same as what we do for Both.

@ikitommi Thoughts? Should we include this implementation on ring-swagger?

EDIT: enums -> Both.

@ikitommi
Copy link
Member

hi. The spec will support deterministic conditionals at some level but the can't support free form s/if, s/conditional and can't support s/either in any case.

What we could do is to create the dispatch functions of all of these into separate namespaces in ring-swagger and mark the implementation (will log a warning or something) as "incompatible with swagger spec - code-gen & ui might barf". One could decide to import those namespaces in projects and use those freely as the schema coercions works ok with those. Api-docs just might look bad with those.

Also, with s/if and s/conditional, we could support out-of-the-box the "deterministic subset" -> one could use those with a supported rules of swagger -> select the sub-schema based on single attribute (e.g. :type) of the schema. This should work with both code-gen and swagger-ui.

@Deraen
Copy link
Member

Deraen commented Sep 4, 2014

0.13.0 release add a new namespace: ring.swagger.json-schema-dirty. You can require that on your code if you need to use s/if, s/conditional, s/either.

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