malli

pieterbreed 2024-08-16T12:36:07.078349Z

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?

ikitommi 2024-08-16T12:42:43.526089Z

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

ikitommi 2024-08-16T12:43:36.182469Z

thanks to Borkdude for making a kick-ass library 😉

pieterbreed 2024-08-16T12:58:04.831059Z

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.

ikitommi 2024-08-16T13:51:14.638589Z

I see, m/deref-recursive?

pieterbreed 2024-08-16T13:51:42.124119Z

I just found it too, and trying to see if I can make it work...

pieterbreed 2024-08-16T13:51:53.941969Z

I think it is doing what I want

👍 1
pieterbreed 2024-08-16T13:56:31.731959Z

Yes, this is going the right direction. My problems has now moved on, in that I am now trying to serialize the functions. thanks3

2024-08-16T17:27:30.978779Z

Not sure this approach will work if you have recursive var reference schemas. But I'm guessing you don't.

pieterbreed 2024-08-16T17:28:21.238189Z

Not recursive ones no