This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-14
Channels
- # beginners (183)
- # boot (6)
- # cider (106)
- # cljs-dev (17)
- # cljsjs (2)
- # cljsrn (2)
- # clojure (56)
- # clojure-italy (14)
- # clojure-nl (39)
- # clojure-spec (49)
- # clojure-uk (138)
- # clojurescript (197)
- # core-logic (37)
- # cursive (22)
- # datascript (5)
- # datomic (29)
- # devcards (18)
- # emacs (1)
- # events (8)
- # figwheel (1)
- # fulcro (59)
- # lein-figwheel (1)
- # leiningen (1)
- # off-topic (54)
- # onyx (3)
- # pedestal (1)
- # portkey (4)
- # re-frame (18)
- # reagent (5)
- # reitit (43)
- # ring (6)
- # ring-swagger (26)
- # shadow-cljs (42)
- # spacemacs (8)
- # specter (12)
- # sql (3)
- # tools-deps (21)
- # vim (18)
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 []}]})
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.
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
ok.. im looking at https://github.com/metosin/compojure-api/blob/2423ba88165c02ee2aa45a44789e4211d71aa02c/src/compojure/api/meta.clj#L409
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