MCPcopy Create free account
hub / github.com/Effect-TS/effect / jsonSchema

Function jsonSchema

packages/effect/src/http/HttpBody.ts:377–387  ·  view source on GitHub ↗
(
  schema: S,
  options?: ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

375 * @since 4.0.0
376 */
377export const jsonSchema = <S extends Schema.Constraint>(
378 schema: S,
379 options?: ParseOptions | undefined
380) => {
381 const encode = SchemaParser.encodeUnknownEffect(Schema.toCodecJson(schema))
382 return (body: S["Type"], contentType?: string): Effect.Effect<Uint8Array, HttpBodyError, S["EncodingServices"]> =>
383 encode(body, options).pipe(
384 Effect.mapError((issue) => new HttpBodyError({ reason: { _tag: "SchemaError", issue }, cause: issue })),
385 Effect.flatMap((body) => json(body, contentType))
386 )
387}
388
389/**
390 * Creates an `application/x-www-form-urlencoded` HTTP body from `UrlParams`.

Callers

nothing calls this directly

Calls 4

jsonFunction · 0.70
toCodecJsonMethod · 0.65
pipeMethod · 0.65
encodeFunction · 0.50

Tested by

no test coverage detected