malli 2025-04-14

I noticed Malli has a json-schema namespace to convert a malli schema into a json schema. I'm used to transformers but the "transform" in there has nothing to do with it right? My issue is that I'd like to transform the schema to match openai requirements for json-schemas, like adding additionalProperties: false on all object schemas Scratching my head as I'm not used to the malli schema being the value I'm trying to transform. Looking at he json-schema namespace it doesn't seem easy to extend like that, seems like I should either pre or post-process the schema?

yeah, use m/walk to transform the schema

see also mu/closed-schema if a recursive {:closed true} is all you need

You could also consider overriding the json-schema accept multimethod for :map schemas 🤔 This would be a global change though.

but I think closing the map schemas is enough for OpenAI

you need to replace optionals by [x. "null"] as well

mu/required-keys makes everything required

which is why you need to replace optionals by [x. "null"] as well