(schema: Schema.Schema<A, I, R>, options?: {
readonly target?: Target | undefined
})
| 262 | * @since 3.10.0 |
| 263 | */ |
| 264 | export const make = <A, I, R>(schema: Schema.Schema<A, I, R>, options?: { |
| 265 | readonly target?: Target | undefined |
| 266 | }): JsonSchema7Root => { |
| 267 | const definitions: Record<string, any> = {} |
| 268 | const target = options?.target ?? "jsonSchema7" |
| 269 | const ast = AST.isTransformation(schema.ast) && isParseJsonTransformation(schema.ast.from) |
| 270 | // Special case top level `parseJson` transformations |
| 271 | ? schema.ast.to |
| 272 | : schema.ast |
| 273 | const jsonSchema = fromAST(ast, { |
| 274 | definitions, |
| 275 | target |
| 276 | }) |
| 277 | const out: JsonSchema7Root = { |
| 278 | $schema: getMetaSchemaUri(target), |
| 279 | $defs: {}, |
| 280 | ...jsonSchema |
| 281 | } |
| 282 | if (Record.isEmptyRecord(definitions)) { |
| 283 | delete out.$defs |
| 284 | } else { |
| 285 | out.$defs = definitions |
| 286 | } |
| 287 | return out |
| 288 | } |
| 289 | |
| 290 | type Target = "jsonSchema7" | "jsonSchema2019-09" | "openApi3.1" | "jsonSchema2020-12" |
| 291 |
nothing calls this directly
no test coverage detected
searching dependent graphs…