there is a Schema Walker in schema-tools if that helps https://github.com/metosin/schema-tools/blob/master/src/schema_tools/walk.cljc
And a (nice?) sample walk in https://github.com/metosin/schema-viz/blob/master/src/schema_viz/core.clj
not sure thou if that's what you were looking for.
There are some interesting things in there, but I don't think I can use it as-is. My use case is to transform a possibly nested schema into a "flat" schema (where the top-level map has only top-level keys). Ie. from {:a {:b {:c s/Str :d s/Int}}} to {:a_b_c s/Str :a_b_d s/Int} So I need to walk and transform, but walk only the leaves, and since
(map? s/Any) ;;=> true
I need a way of detecting "primitive" schemas(unless I misunderstood some things in walk - not familiar with the internals of schema)
like plumbing.map/[flatten|unflatten]
for Schemas? If you only have nestes schema maps, it should be easy to walk over different keys (required, optional, normal). Schema-tools has some helpers for the keys. If you want to support also things like s/maybe
in the path or sequential schemas, then haven't seen anything ready out there.
Yes, similar to that 🙂
There are no maybe
in the path (but optional-key
yes). And there are annoyances with s/if
as well.
Looks like I will have to make my own 🙂
Maybe taking plumbing.map/[flatten|unflatten] and modifying it for schemas would work