2024-07-02 15:02:35 +02:00
|
|
|
/*
|
|
|
|
|
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
|
|
|
|
<info@greenscale.de>
|
|
|
|
|
|
|
|
|
|
»heimdall« is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
»heimdall« is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with »heimdall«. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2023-06-18 23:29:57 +02:00
|
|
|
namespace _heimdall.helpers.json_schema
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2023-07-06 16:13:26 +02:00
|
|
|
/*
|
2023-06-19 18:27:04 +02:00
|
|
|
type type_name = (
|
2023-06-18 23:29:57 +02:00
|
|
|
"null"
|
|
|
|
|
|
|
|
|
|
|
"boolean"
|
|
|
|
|
|
|
|
|
|
|
"integer"
|
|
|
|
|
|
|
|
|
|
|
"float"
|
|
|
|
|
|
|
|
|
|
|
"string"
|
|
|
|
|
|
|
|
|
|
|
"array"
|
|
|
|
|
|
|
|
|
|
|
"object"
|
|
|
|
|
);
|
2023-07-06 16:13:26 +02:00
|
|
|
*/
|
2023-06-18 23:29:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-19 18:27:04 +02:00
|
|
|
* @see https://json-schema.org/
|
|
|
|
|
* @see https://json-schema.org/understanding-json-schema/reference/type.html
|
2023-06-18 23:29:57 +02:00
|
|
|
*/
|
2023-06-19 18:27:04 +02:00
|
|
|
export type type_schema = (
|
|
|
|
|
{
|
|
|
|
|
description ?: string;
|
|
|
|
|
deprecated ?: boolean;
|
|
|
|
|
}
|
|
|
|
|
&
|
|
|
|
|
(
|
2023-07-27 17:37:45 +02:00
|
|
|
{
|
|
|
|
|
type : "any";
|
|
|
|
|
default ?: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-19 18:27:04 +02:00
|
|
|
{
|
|
|
|
|
type : "null";
|
2023-07-27 17:37:45 +02:00
|
|
|
default ?: null;
|
2023-06-19 18:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
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>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
{
|
2023-07-06 16:13:26 +02:00
|
|
|
type : "array";
|
2023-06-19 18:27:04 +02:00
|
|
|
items ?: type_schema;
|
|
|
|
|
default ?: Array<any>;
|
|
|
|
|
enum ?: Array<Array<any>>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
{
|
2023-07-27 17:37:45 +02:00
|
|
|
anyOf : Array<type_schema>;
|
|
|
|
|
default ?: any;
|
2023-06-19 18:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
{
|
2023-07-27 17:37:45 +02:00
|
|
|
allOf : Array<type_schema>;
|
|
|
|
|
default ?: any;
|
2023-06-19 18:27:04 +02:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
2023-06-18 23:29:57 +02:00
|
|
|
|
|
|
|
|
}
|