MCPcopy Index your code
hub / github.com/Effect-TS/effect / pruneJsonSchemaAnnotations

Function pruneJsonSchemaAnnotations

packages/effect/src/JSONSchema.ts:472–498  ·  view source on GitHub ↗
(
  ast: AST.AST,
  description: string | undefined,
  title: string | undefined,
  def: Option.Option<unknown>,
  examples: ReadonlyArray<unknown> | undefined
)

Source from the content-addressed store, hash-verified

470}
471
472function pruneJsonSchemaAnnotations(
473 ast: AST.AST,
474 description: string | undefined,
475 title: string | undefined,
476 def: Option.Option<unknown>,
477 examples: ReadonlyArray<unknown> | undefined
478): JsonSchemaAnnotations | undefined {
479 const out: JsonSchemaAnnotations = {}
480 if (description !== undefined) out.description = description
481 if (title !== undefined) out.title = title
482 if (Option.isSome(def)) {
483 const o = encodeDefault(ast, def.value)
484 if (Option.isSome(o) && isJsonValue(o.value)) {
485 out.default = o.value
486 }
487 }
488 if (examples !== undefined) {
489 const encodedExamples = encodeExamples(ast, examples)
490 if (encodedExamples !== undefined) {
491 out.examples = encodedExamples
492 }
493 }
494 if (Object.keys(out).length === 0) {
495 return undefined
496 }
497 return out
498}
499
500function getContextJsonSchemaAnnotations(ast: AST.AST, annotated: AST.Annotated): JsonSchemaAnnotations | undefined {
501 return pruneJsonSchemaAnnotations(

Callers 2

getJsonSchemaAnnotationsFunction · 0.85

Calls 4

encodeDefaultFunction · 0.85
isJsonValueFunction · 0.85
encodeExamplesFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected