( ast: AST.AST, description: string | undefined, title: string | undefined, def: Option.Option<unknown>, examples: ReadonlyArray<unknown> | undefined )
| 470 | } |
| 471 | |
| 472 | function 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 | |
| 500 | function getContextJsonSchemaAnnotations(ast: AST.AST, annotated: AST.Annotated): JsonSchemaAnnotations | undefined { |
| 501 | return pruneJsonSchemaAnnotations( |
no test coverage detected
searching dependent graphs…