UNPKG

json-schema-library

Version:

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation

18 lines (16 loc) 410 B
import { JsonSchema } from "../types"; export function createOneOfSchemaResult( schema: JsonSchema, oneOfSchema: JsonSchema, oneOfIndex: number ) { const childSchema = { ...oneOfSchema }; Object.defineProperty(childSchema, "getOneOfOrigin", { enumerable: false, value: () => ({ index: oneOfIndex, schema }) }); return childSchema; }