Fork me on GitHub
#malli
<
2023-10-09
>
Casey13:10:20

Is there any existing tools for consuming openapi schemas and producing malli schemas from the openapi data models?

hifumi12323:10:30

if i recall correctly, OpenAPI uses JSON schema, so you would want to try the patches in https://github.com/metosin/malli/pull/211

Casey07:10:39

Ah that's the search keyword I was missing. I'll have a crack at that patch.

sergey.shvets19:10:42

Hi, I'm trying to validate that one and only one of two keys in a map is present. e.g {:block/prop1 1 :block/prop2 2 :block/children []} or {:block/prop1 1 :block/prop2 2 :block/markup "markup"} I want to make sure that only markup or children key is present. Is there a better way to do it without going for multi-schema? Ideally, I'd like to validate keys separately and then for keys that present validate that their attributes/values are of a proper type/shape.

opqdonut05:10:58

you could use [:and [:map ...] [:fn ...]], see https://github.com/metosin/malli#fn-schemas

dvingo14:10:51

I was playing around with an idea of adding a :custom-pred property to the -map-schema https://app.slack.com/client/T03RZGPFR/CLDK6MFMK https://github.com/dvingo/malli/commit/1f3d00f8abbc0aafede329d558931f110427f3b5 That would support use-cases like yours in an extensible way. Something like:

[custom-map-schema {:exclusive-keys #{:block/markup :block/children}}
  [..etc]] 
I think it would be similar to the :compile property supported by -collection-schema but I'm not exactly sure how that works https://github.com/metosin/malli/blob/39ccfef96b54beb3d862b1eab5f5be90ec0f4456/src/malli/core.cljc#L1188