Fork me on GitHub
#ring-swagger
<
2017-04-28
>
martyglaubitz12:04:58

How does one define the schema of a response as array of objects which's defintion can be referenced? I tried: :schema [{:$ref "#/definitions/User"}] but this will get me don't know how to convert #/definitions/User into a Swagger Schema

ikitommi12:04:30

try :schema [Schema]?

ikitommi12:04:47

if the Schema is a defined plumatic Schema.

ikitommi12:04:14

ring-swagger resolves the references from Plumatic Schema metadata.

martyglaubitz12:04:56

@ikitommi ok, can't i use normal schema defintions like:

:definitions {"User" {:type "object"
                           :properties {:name {:type "string"}
                                        :password {:type "string"}}
                           :additionalProperties false
                           :required (:name :password)}}}

martyglaubitz12:04:59

btw: you suggestion worked

ikitommi12:04:35

No, currently you can’t mix JSON Schema & Plumatic Schemas, do you have a use case for needing to mix those?

martyglaubitz12:04:53

oh and: this is a play project, i'd never expose users passwords in a reponse 😄

martyglaubitz12:04:27

@ikitommi no, now that i see its more convinient to use defschema, i woulnd't see that

ikitommi12:04:22

@lambder looks like a bug. But swagger 2.0 doesn’t support :anyOf, so we in the end, we have to produce something. With either it takes the first one of the list. But it should be R I think. Would you like to fix it?

lambder12:04:57

@ikitommi but swagger 2.0 support discriminator

lambder13:04:09

@ikitommi there is allOf, can ring-swagger somehow make use of it?

ikitommi14:04:34

@lambder both :anyOf and :oneOf are in 3.0. Would someone be interested in adding support for that? maybe a swagger3 ns? My 3 years old issue for the either btw: https://github.com/OAI/OpenAPI-Specification/issues/57

ikitommi14:04:50

the discriminator could be used, PRs welcome. I guess it works only with maps?

ikitommi14:04:43

here are btw the clojure.spec to JSON Schema mappings (with :anyOf and :oneOf): https://github.com/metosin/spec-tools/blob/master/src/spec_tools/json_schema.cljc