Fork me on GitHub
#malli
<
2023-02-01
>
geraldodev01:02:34

"I'm looking at the ring-malli-lite-swagger and ring-malli-swagger of reitit and the differences in the server.clj are just in the syntax. So it looks like reitit recognizes the lite syntax without configuration. It's very nice that we can use assoc/dissoc/merge in plain Clojure and reduce clutter."

ingesol12:02:57

How would you write a function schema for (defn foo [a & {:keys [b c}] ...) ?

delaguardo12:02:56

You could use malli.destructure to infer a schema.

user=> (require '[malli.destructure :as md])
nil
user=> (defn foo [a & {:keys [b c]}])
#'user/foo
user=> (md/infer #'foo)
[:=> [:cat :any [:altn [:map [:map [:b {:optional true} :any] [:c {:optional true} :any]]] [:args [:* [:alt [:cat [:= :b] :any] [:cat [:= :c] :any] [:cat :any :any]]]]]] :any]

ingesol14:02:10

Great thanks, didn’t remember that one

Bart Kleijngeld17:02:21

Does someone know if there's a way to have :malli/schema metadata on functions be rendered into documentation by Codox?

Bart Kleijngeld17:02:33

So the function schema would be visible in the docs for that function. Even a plain text dump would be nice.

Ben Sless17:02:42

You could probably do it in codox by configuring which metadata it looks at

Bart Kleijngeld17:02:23

Yeah you're probably right. And I expect whatever theme I'll be using must also be extended to show that metadata.

escherize17:02:28

If you need to produce strings / explainations there’s malli.experimental.describe/describe too!

escherize17:02:24

We are using that to generate some simple docs ^

Bart Kleijngeld19:02:25

That may come in handy, thanks :)

frank17:02:10

has any progress been made on this front?

Benjamin19:02:35

https://json-schema.org/ is there tool that generates malli from json schema and would this be useful? I was doing something with google docs api in the past and it might have been mildly useful

Noah Bogart19:02:40

There's https://github.com/metosin/malli/issues/54 about it, along with this https://github.com/metosin/malli/pull/211. Maybe you or someone else could pick it up and finish it? I'd also love to have this functionality but my job only allows me enough time to fix a bug here or there.

Ben Sless19:02:54

There's also a gist I shared some time ago in malli, need to dig it up