UNPKG

@flodejs/json-schema-editor-antd

Version:
128 lines (127 loc) 4.19 kB
import { CSSProperties } from 'react'; export type SchemaEditorProps = { value?: JSONSchema | undefined | string; style?: CSSProperties; onSchemaChange?: (schema: JSONSchema) => void; handleAdvancedSettingClick?: (namePath: number[], schema: JSONSchema, propertyName?: string) => boolean; }; /** * Primitive type * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1 */ export type JSONSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null'; /** * Primitive type * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1 */ export type JSONSchemaType = string | number | boolean | JSONSchemaObject | JSONSchemaArray | null; export interface JSONSchemaObject { [key: string]: JSONSchemaType; } export type JSONSchemaArray = Array<JSONSchemaType>; /** * Meta schema * * Recommended values: * - 'http://json-schema.org/schema#' * - 'http://json-schema.org/hyper-schema#' * - 'https://json-schema.org/draft/2020-12/schema#' * - 'http://json-schema.org/draft/2020-12/hyper-schema#' * * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5 */ export type JSONSchemaVersion = string; /** * JSON Schema v7 * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01 */ export type JSONSchemaDefinition = JSONSchema | boolean; export interface JSONSchema { $id?: string; $ref?: string; $schema?: JSONSchemaVersion; $comment?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1 */ type?: JSONSchemaTypeName | JSONSchemaTypeName[]; enum?: JSONSchemaType[]; const?: JSONSchemaType; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2 */ multipleOf?: number; maximum?: number; exclusiveMaximum?: number; minimum?: number; exclusiveMinimum?: number; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3 */ maxLength?: number; minLength?: number; pattern?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4 */ items?: JSONSchemaDefinition | JSONSchemaDefinition[]; additionalItems?: JSONSchemaDefinition; maxItems?: number; minItems?: number; uniqueItems?: boolean; contains?: JSONSchema; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5 */ maxProperties?: number; minProperties?: number; required?: string[]; properties?: { [key: string]: JSONSchemaDefinition; }; patternProperties?: { [key: string]: JSONSchemaDefinition; }; additionalProperties?: JSONSchemaDefinition; dependencies?: { [key: string]: JSONSchemaDefinition | string[]; }; propertyNames?: JSONSchemaDefinition; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6 */ if?: JSONSchemaDefinition; then?: JSONSchemaDefinition; else?: JSONSchemaDefinition; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7 */ allOf?: JSONSchemaDefinition[]; anyOf?: JSONSchemaDefinition[]; oneOf?: JSONSchemaDefinition[]; not?: JSONSchemaDefinition; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7 */ format?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8 */ contentMediaType?: string; contentEncoding?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9 */ definitions?: { [key: string]: JSONSchemaDefinition; }; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10 */ title?: string; description?: string; default?: JSONSchemaType; readOnly?: boolean; writeOnly?: boolean; examples?: JSONSchemaType; }