Fork me on GitHub
#ring-swagger
<
2016-11-18
>
sammikko06:11:14

hi.. is it supported to use sequence of custom types in a schema... something like {:id s/Int :collection [AnotherSchema]} ? having some trouble with it.. says "don't know how to convert"

ikitommi06:11:26

{:id s/Str, :drinks [Drink]}} should work

ikitommi06:11:47

but what is AnotherSchema?

sammikko06:11:22

thanks... i actually tried it and it works.. but in my code where its not working, the problematic collection is in a schema defined by "abstract-map-schema" .. im using it as a sort of "base class" to get some common properties to extended schemas.. ill try to make a small example with abstract-map-schema

sammikko06:11:28

AnotherSchema is just a simple schema: something like (def AnotherSchema {:id s/Int :name s/Str})

ikitommi06:11:14

ah. The abstract-map-schema is problematic, swagger doesn't support one-of or any-of. There is a mapping for it in

ikitommi06:11:31

try importing that. And if you know how the mapping should be implemented, please PR, we could add it to default mappings. Currently could emit broken swagger spec..

ikitommi06:11:30

swagger3.0 should support those, but not out yet.

sammikko07:11:41

i see ok... i tried json_schema_dirty too, but didnt help

sammikko07:11:24

its just enough to add (:use [ring.swagger.json-schema-dirty]) in my namespace, right?

ikitommi07:11:58

yes, it's enough. Could you paste the error you get?

sammikko07:11:42

now it outputs: "<span class="strong">AbstractBaseSchema is not defined!</span>" in swagger

sammikko07:11:51

when i look at the actual swagger.json generated:

sammikko07:11:51

that seems right.. im not sure how that $ref thing is supposed to work..

ikitommi07:11:26

@sammikko I guess there is not a [:definitions “AbstractBaseSchema”] in the swagger.json?

sammikko07:11:51

no, :definitions is empty

ikitommi07:11:47

ok, that’s not right. But as said, the abstract-* schemas are not supported. Please file a issue out of that.

ikitommi07:11:11

can you work without the abstract-schemas for now?

sammikko07:11:22

sure, ok.. thanks!

ikitommi07:11:33

might be easy to fix, but don’t have time now. PRs welcome 🙂

sammikko07:11:02

yeah, i was just thinking if i could make it with just ordinary maps and use merge or something

sammikko07:11:35

i probably need to use separate paths /concretetype1, /concretetype2 etc. for the POST requests used to create those types to be able to generate sensible swagger 2.0 out of it.. i think thats what you ment by that "one-of" or "any-of" is not supported in swagger 2.0

ikitommi07:11:28

If you can figure out how to do the abstract-stuff with the swagger discriminator, would be awesome.

sammikko08:11:55

ok.. you mean just the problem that :definitions is empty? im using "allOf" so that should be doable..