clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
Eugen 2020-09-29T08:39:04.034500Z

hi, is there some tooling to generate spec code from XSD schema files ? I would like to validate with clojurescript (if possible) some OFX XML I generate

2020-09-29T14:16:53.037900Z

I tried both of the XSD parsers I found using Google search (which looks like they came from the same root). Neither of them seemed to work. clj-xml will parse an XSD, but moving on from the parsed XML to a spec seems to still be a work-in-progress.

👍 1
mpenet 2020-09-29T16:13:45.039800Z

I have a case where I generate specs, and sometimes I have fwd declarations in spec alises: (s/def ::foo ::bar) where ::bar is not declared/speced yet, so it blows up of course. A dirty way to do that is to do (s/and ::bar) as spec for instance but I am sure there's a better way (short of building a dep graph and specing in order)?

alexmiller 2020-09-29T16:15:07.040800Z

Forward references are actually intended to be ok in specs - the spec alias case (s/def ::foo ::bar) is one known exception to that (there is a ticket for this)

alexmiller 2020-09-29T16:15:32.041100Z

not sure if you've tried (s/spec ::bar) - that might also work

alexmiller 2020-09-29T16:15:46.041400Z

would be slightly less dirty if so

mpenet 2020-09-29T16:16:21.041800Z

I tried s/spec, doesn't work

alexmiller 2020-09-29T16:16:44.042200Z

well, can't say I have a better alternative for you then

mpenet 2020-09-29T16:16:46.042300Z

"unable to resolve spec ::bar "

mpenet 2020-09-29T16:17:08.042800Z

alright, thanks for the info. If it's a bug I'll take the s/and trick as acceptable for now

mpenet 2020-09-29T16:19:43.043200Z

I cannot find the jira for it, but I am not a good at jira'ing

alexmiller 2020-09-29T16:52:47.043500Z

https://clojure.atlassian.net/browse/CLJ-2067

mpenet 2020-09-29T17:05:55.044300Z

Thanks!