schema

ikitommi 2017-09-22T04:57:59.000114Z

there is a Schema Walker in schema-tools if that helps https://github.com/metosin/schema-tools/blob/master/src/schema_tools/walk.cljc

ikitommi 2017-09-22T04:59:40.000083Z

And a (nice?) sample walk in https://github.com/metosin/schema-viz/blob/master/src/schema_viz/core.clj

ikitommi 2017-09-22T05:01:49.000177Z

not sure thou if that's what you were looking for.

2017-09-22T08:17:00.000214Z

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

2017-09-22T08:18:33.000373Z

(unless I misunderstood some things in walk - not familiar with the internals of schema)

ikitommi 2017-09-22T13:52:38.000619Z

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.

2017-09-22T17:09:06.000115Z

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 🙂

2017-09-22T17:10:27.000474Z

Maybe taking plumbing.map/[flatten|unflatten] and modifying it for schemas would work