Openapi.fits: def of ezmcp@0.1.0.0 Import: import ezmcp@0.1.0.0/src/openapi.bend as Openapi Lines 1420-1428 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=1420&end_line=1428 import Base import emerging-ezjson@1.2.0.0/main.bend as Json import emerging-ezjson@1.2.0.0/src/value.bend as Value # whether a value fits a property's schema, one level deep: its `type` # (`typed`), one of its `anyOf` alternatives' types when it has `anyOf`, # and one of its `enum` values when it has `enum` def fits(+sch: Value.Json, +val: Value.Json) -> Bool: +any = Json.get(sch, "anyOf") +en = Json.get(sch, "enum") Bool.and(typed(Json.get(sch, "type"), val), Bool.and(Bool.or(Bool.not(Json.is_arr(any)), alts(Json.items(any), val)), Bool.or(Bool.not(Json.is_arr(en)), same.json(val, Json.items(en))))) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=emerging-ezjson@1.3.0.0/main.bend&name=get https://jend.leeeet.dev/definition.txt?path=emerging-ezjson@1.3.0.0/main.bend&name=is_arr https://jend.leeeet.dev/definition.txt?path=emerging-ezjson@1.3.0.0/main.bend&name=items 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=ezmcp@0.1.0.0/src/openapi.bend&name=alts https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=same.json https://jend.leeeet.dev/definition.txt?path=ezmcp@0.1.0.0/src/openapi.bend&name=typed