Hi Everyone, I have conflicting requirements and could use some suggestions for resolving these:
• On the one hand I use the var-references when defining specs (because it creates sensible definitionswhen exporting to JSONSchema documents)
• On the other hand, I am trying to serialize and de-serialize the malli specs using malli.edn, which on read fails with error :malli.edn/var-parsing-not-supported, which is totally understandable.
I'm assuming I could take the malli schema as a value, walk it, and (resolve ...) all the var references as part of write. Does this seem sensible or am I missing something obvious? Is there a better approach to solving this issue?
you can deserialize the vars using edamame, here’s an example: https://github.com/metosin/malli/blob/master/test/malli/core_test.cljc#L3331-L3337
thanks to Borkdude for making a kick-ass library 😉
If I'm not mistaken this would de-serialize the refs into refs, right? This will not work for me. I need to store the spec in a durable/complete way. The behaviour that I need is for the referenced schemas to be serialized into the output.
I see, m/deref-recursive?
I just found it too, and trying to see if I can make it work...
I think it is doing what I want
Yes, this is going the right direction. My problems has now moved on, in that I am now trying to serialize the functions. thanks3
Not sure this approach will work if you have recursive var reference schemas. But I'm guessing you don't.
Not recursive ones no