how can i write a recursive schema like:
(s/defschema TaskTemplateSubmission
{:name s/Str
:description s/Str
:children [TaskTemplateSubmission]})
which is basically a tree.
The error i get is:
ERROR error converting to swagger schema [:children [#object[clojure.lang.Var$Unbound 0x363d3f4b "Unbound: #'api.schema/TaskTemplateSubmission"]]]
java.lang.IllegalArgumentException: error converting to swagger schema [:children [#object[clojure.lang.Var$Unbound 0x363d3f4b "Unbound: #'api.schema/TaskTemplateSubmission"]]]
@er.puneetpahuja would :children [(s/recursive TaskTemplateSubmission)]
work?
nope
Exception in thread "main" java.lang.RuntimeException: Not an IDeref: Unbound: #'api.schema/TaskTemplateSubmission, compiling:(schema.clj:304:18)
this was with [metosin/compojure-api "1.1.11"]. when i switched to "2.0.0-alpha20", only the UI breaks (https://imgur.com/a/cjuJksA) but there is no error on console.
Looking at the schema docs, here's the syntax:
;; recursive
(def Tree {:value s/Int :children [(s/recursive #'Tree)]})
(s/validate Tree {:value 0, :children [{:value 1, :children []}]})
Worked. Thanks a lot š Can you share the link of the docs.
Thanks again š Saw something similar here : https://stackoverflow.com/questions/36866035/how-to-refer-to-enclosing-type-definition-recursively-in-yaml-swagger-io But i thought its a yaml specific thing.
swagger doesnāt support those very well, but at least it doesnāt blow up.
Are multipart-forms supported in ring-swagger? I have a multipart-form where I'm uploading the file along with some string parameters and looking to document this with Ring Swagger.. I found some example using compojure api, but I'm using ring-swagger directly
should be, just check the swagger data that compojure-api emits. I think it required setting :consumes
. and https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/upload.clj has the schemas for different upload types
you can mix them with other (form-)parameters.
ok.. im looking at https://github.com/metosin/compojure-api/blob/2423ba88165c02ee2aa45a44789e4211d71aa02c/src/compojure/api/meta.clj#L409
this is some internal format of compojure-api, not swagger data yet?
code to generate the ring-swagger compatible definition, e.g. the :consumes
& the parameter type.
thanks! I had to add the :consumes and the parameters part was something like :parameters {:formData {:file upload/TempFileUpload}}
š
so i have a lot of schema definitions that have example data added to them with ring.swagger.json-schema/describe. iām now trying to use those schema definitions from clojurescript but it seems like describe isnāt clojurescript compatible
iām pretty new to clojurescript but is there a reason that shouldnāt work? clojurescript seems to support attaching metadata
i guess the rest of that namespace is pretty jvm-centric so maybe it just hasnāt been worth to make all of that clojurescript friendly
iām thinking i should just be able to implement my own wrapper for describe that does nothing for clojurescript and dispatches to the real describe for clojure
@nickmbailey we have been porting stuff from ring-swagger to both schema-tools and spec-tools - for both coercion & swagger2-transformation. Itās not complete, but grand goal is to have unified api for Schema/Spec and for Clojure/ClojureScript. With this, the describe
will be replaced with something like https://github.com/metosin/schema-tools/issues/32 and https://github.com/metosin/spec-tools/issues/23
might not help you just now, but wanted you to know. there are lot of āhelp wantedā issues tooā¦ š
awesome, good to know š
and hint noticed haha
i havenāt had time to dive into spec yet