core/source/logic/helpers/json_schema.ts
Christian Fraß cf9c4f009d [mod] source
2023-07-27 17:37:45 +02:00

118 lines
1.7 KiB
TypeScript

namespace _heimdall.helpers.json_schema
{
/**
*/
/*
type type_name = (
"null"
|
"boolean"
|
"integer"
|
"float"
|
"string"
|
"array"
|
"object"
);
*/
/**
* @see https://json-schema.org/
* @see https://json-schema.org/understanding-json-schema/reference/type.html
*/
export type type_schema = (
{
description ?: string;
deprecated ?: boolean;
}
&
(
{
type : "any";
default ?: any;
}
|
{
type : "null";
default ?: null;
}
|
{
type : "boolean";
default ?: boolean;
enum ?: Array<boolean>;
}
|
{
type : "integer";
default ?: int;
enum ?: Array<int>;
minimum ?: int;
exclusiveMinimum ?: int;
maximum ?: int;
exclusiveMaximum ?: int;
}
|
{
type : "number";
default ?: float;
enum ?: Array<float>;
minimum ?: float;
exclusiveMinimum ?: float;
maximum ?: float;
exclusiveMaximum ?: float;
}
|
{
type : "string";
default ?: string;
enum ?: Array<string>;
minLength ?: int;
maxLength ?: int;
pattern ?: string;
}
|
/**
* @see https://json-schema.org/understanding-json-schema/reference/object.html#object
*/
{
type : "object";
additionalProperties ?: (
false
|
type_schema
);
properties ?: Record<string, type_schema>;
required ?: Array<string>;
unevaluatedProperties ?: boolean;
default ?: Object;
enum ?: Array<Object>;
}
|
{
type : "array";
items ?: type_schema;
default ?: Array<any>;
enum ?: Array<Array<any>>;
}
|
{
anyOf : Array<type_schema>;
default ?: any;
}
|
{
allOf : Array<type_schema>;
default ?: any;
}
)
);
}