Openapi.shape: def of ezmcp@0.1.0.0 Import: import ezmcp@0.1.0.0/src/openapi.bend as Openapi Lines 565-588 of ezmcp@0.1.0.0/src/openapi.bend: https://jend.leeeet.dev/read.txt?path=ezmcp@0.1.0.0/src/openapi.bend&start_line=565&end_line=588 import Base import emerging-ezjson@1.2.0.0/src/value.bend as Value # a schema as an input schema (`own`), its properties' and items' schemas # mapped the same way; or the cells of a properties object with every # schema value mapped, a boolean kept and any other value left out. `fuel` # bounds how deep schemas nest def shape(fuel: Nat, val: Value.Json, read: Read) -> Value.Json: match fuel: case 0n: val case 1n+(+less): match val read: case Value.JObj{pairs} ASchema{}: +ps = own(members(Value.JObj{pairs})) kids.put(ps, kids(ps), cs => shape(less, cs, AProps{}), got => shape(less, got, ASchema{})) case Value.JPair{key, +item, rest} AProps{}: prop.put(prop.of(item), key, item, got => shape(less, got, ASchema{}), shape(1n+less, rest, AProps{})) case Value.JBind{src, +n, +item, rest} AProps{}: prop.put(prop.of(item), Value.span.str(src, n, U32.is_zero(n)), item, got => shape(less, got, ASchema{}), shape(1n+less, rest, AProps{})) case other ASchema{}: other case other AProps{}: Value.JNil{} Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_zero https://jend.leeeet.dev/definition.txt?path=emerging-ezjson@1.3.0.0/src/value.bend&name=Json https://jend.leeeet.dev/definition.txt?path=emerging-ezjson@1.3.0.0/src/value.bend&name=span.str https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=Read https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=kids https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=kids.put https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=members https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=own https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=prop.of https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=prop.put