Hyperlinkv0.8.0-beta.28

Schema

Schema.toStandardJSONSchemaV1functioneffect/Schema.ts:1235
<S extends Constraint>(self: S): StandardJSONSchemaV1<
  S["Encoded"],
  S["Type"]
> &
  S

Converts a schema to an experimental Standard JSON Schema V1 representation.

Details

https://github.com/standard-schema/standard-schema/pull/134

Standard Schema
Source effect/Schema.ts:123526 lines
export function toStandardJSONSchemaV1<S extends Constraint>(
  self: S
): StandardJSONSchemaV1<S["Encoded"], S["Type"]> & S {
  const jsonSchema: StandardJSONSchemaV1.Props<S["Encoded"], S["Type"]>["jsonSchema"] = {
    input(options) {
      return toBaseStandardJSONSchemaV1(self, options.target)
    },
    output(options) {
      return toBaseStandardJSONSchemaV1(toType(self), options.target)
    }
  }
  if ("~standard" in self) {
    const out = self as any
    if ("jsonSchema" in out["~standard"]) return out
    Object.assign(out["~standard"], { jsonSchema })
    return out
  } else {
    return Object.assign(self, {
      "~standard": {
        version: 1,
        vendor: "effect",
        jsonSchema
      } as const
    })
  }
}
Referenced by 1 symbols