186 lines
3.4 KiB
TypeScript
186 lines
3.4 KiB
TypeScript
|
|
namespace formgen.helpers.json_schema
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
export type type_schema_any = {
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/null
|
||
|
|
*/
|
||
|
|
export type type_schema_null = {
|
||
|
|
type : "null";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/boolean
|
||
|
|
*/
|
||
|
|
export type type_schema_boolean = {
|
||
|
|
type : "boolean";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/numeric#integer
|
||
|
|
*/
|
||
|
|
export type type_schema_integer = {
|
||
|
|
type : "integer";
|
||
|
|
multipleOf ?: int;
|
||
|
|
minimum ?: int;
|
||
|
|
exclusiveMinimum ?: int;
|
||
|
|
maximum ?: int;
|
||
|
|
exclusiveMaximum ?: int;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/numeric#number
|
||
|
|
*/
|
||
|
|
export type type_schema_number = {
|
||
|
|
type : "number";
|
||
|
|
multipleOf ?: int;
|
||
|
|
minimum ?: int;
|
||
|
|
exclusiveMinimum ?: int;
|
||
|
|
maximum ?: int;
|
||
|
|
exclusiveMaximum ?: int;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/string
|
||
|
|
*/
|
||
|
|
export type type_schema_string = {
|
||
|
|
type : "string";
|
||
|
|
minLength ?: int;
|
||
|
|
maxLength ?: int;
|
||
|
|
pattern ?: string;
|
||
|
|
format ?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/array
|
||
|
|
*/
|
||
|
|
export type type_schema_array = {
|
||
|
|
type : "array";
|
||
|
|
items ?: type_schema;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/object
|
||
|
|
*/
|
||
|
|
export type type_schama_object = {
|
||
|
|
type : "object";
|
||
|
|
properties ?: Record<string, type_schema>;
|
||
|
|
required ?: Array<string>;
|
||
|
|
additionalProperties ?: (false | type_schema);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/combining#not
|
||
|
|
*/
|
||
|
|
export type type_schema_combination_not = {
|
||
|
|
not : Array<type_schema>;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/combining#oneOf
|
||
|
|
*/
|
||
|
|
export type type_schema_combination_one_of = {
|
||
|
|
oneOf : Array<type_schema>;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/combining#anyOf
|
||
|
|
*/
|
||
|
|
export type type_schema_combination_any_of = {
|
||
|
|
anyOf : Array<type_schema>;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/combining#allOf
|
||
|
|
*/
|
||
|
|
export type type_schema_combination_all_of = {
|
||
|
|
allOf : Array<type_schema>;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @todo $id
|
||
|
|
* @todo const
|
||
|
|
* @todo if-then-else
|
||
|
|
*/
|
||
|
|
export type type_schema = (
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/keywords#dollarref
|
||
|
|
* /
|
||
|
|
*/
|
||
|
|
$ref ?: string;
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/annotations
|
||
|
|
*/
|
||
|
|
title ?: string;
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/generic
|
||
|
|
*/
|
||
|
|
enum ?: Array<any>;
|
||
|
|
/**
|
||
|
|
* @see https://json-schema.org/understanding-json-schema/reference/annotations
|
||
|
|
*/
|
||
|
|
default ?: any;
|
||
|
|
}
|
||
|
|
&
|
||
|
|
(
|
||
|
|
/*
|
||
|
|
type_schema_any
|
||
|
|
|
|
||
|
|
*/
|
||
|
|
type_schema_null
|
||
|
|
|
|
||
|
|
type_schema_boolean
|
||
|
|
|
|
||
|
|
type_schema_integer
|
||
|
|
|
|
||
|
|
type_schema_number
|
||
|
|
|
|
||
|
|
type_schema_string
|
||
|
|
|
|
||
|
|
type_schema_array
|
||
|
|
|
|
||
|
|
type_schama_object
|
||
|
|
|
|
||
|
|
type_schema_combination_not
|
||
|
|
|
|
||
|
|
type_schema_combination_one_of
|
||
|
|
|
|
||
|
|
type_schema_combination_any_of
|
||
|
|
|
|
||
|
|
type_schema_combination_all_of
|
||
|
|
)
|
||
|
|
);
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
export type type_root = (
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @see hhttps://json-schema.org/understanding-json-schema/keywords#dollardefs
|
||
|
|
*/
|
||
|
|
$defs : Map<string, type_schema>;
|
||
|
|
}
|
||
|
|
&
|
||
|
|
type_schema
|
||
|
|
);
|
||
|
|
|
||
|
|
}
|