This commit is contained in:
Mars 2024-06-08 14:10:59 -04:00
parent a743cdabe5
commit bd402f57f5
Signed by: pupbrained
GPG key ID: 874E22DF2F9DFCB5
276 changed files with 37936 additions and 22932 deletions

View file

@ -12,14 +12,14 @@
namespace rfl::json::schema {
template <class T>
struct JSONSchema {
Rename<"$schema", Literal<"https://json-schema.org/draft/2020-12/schema">>
schema;
Flatten<T> root;
std::map<std::string, Type> definitions;
};
template <class T>
struct JSONSchema {
Rename<"$schema", Literal<"https://json-schema.org/draft/2020-12/schema">>
schema;
Flatten<T> root;
std::map<std::string, Type> definitions;
};
} // namespace rfl::json::schema
} // namespace rfl::json::schema
#endif

View file

@ -12,136 +12,151 @@
namespace rfl::json::schema {
/// The JSON representation of internal::schema::Type.
struct Type {
struct Boolean {
std::optional<std::string> description;
Literal<"boolean"> type;
/// The JSON representation of internal::schema::Type.
struct Type {
struct Boolean {
std::optional<std::string> description;
Literal<"boolean"> type;
};
struct Integer {
Literal<"integer"> type;
std::optional<std::string> description;
};
struct Number {
Literal<"number"> type;
std::optional<std::string> description;
};
struct String {
Literal<"string"> type;
std::optional<std::string> description;
};
using NumericType = std::variant<Integer, Number>;
struct AllOf {
std::optional<std::string> description;
std::vector<Type> allOf;
};
struct AnyOf {
std::optional<std::string> description;
std::vector<Type> anyOf;
};
struct ExclusiveMaximum {
std::optional<std::string> description;
std::variant<double, int> exclusiveMaximum;
std::string type;
};
struct ExclusiveMinimum {
std::optional<std::string> description;
std::variant<double, int> exclusiveMinimum;
std::string type;
};
struct FixedSizeTypedArray {
Literal<"array"> type;
std::optional<std::string> description;
rfl::Ref<Type> items;
size_t minContains;
size_t maxContains;
};
struct Maximum {
std::optional<std::string> description;
std::variant<double, int> maximum;
std::string type;
};
struct Minimum {
std::optional<std::string> description;
std::variant<double, int> minimum;
std::string type;
};
struct Null {
Literal<"null"> type;
std::optional<std::string> description;
};
struct Object {
Literal<"object"> type;
std::optional<std::string> description;
std::map<std::string, Type> properties;
std::vector<std::string> required;
};
struct OneOf {
std::optional<std::string> description;
std::vector<Type> oneOf;
};
struct Reference {
Rename<"$ref", std::optional<std::string>> ref;
std::optional<std::string> description;
};
struct Regex {
Literal<"string"> type;
std::optional<std::string> description;
std::string pattern;
};
struct StringEnum {
Literal<"string"> type;
std::optional<std::string> description;
rfl::Rename<"enum", std::vector<std::string>> values;
};
struct StringMap {
Literal<"object"> type;
std::optional<std::string> description;
rfl::Ref<Type> additionalProperties;
};
struct Tuple {
Literal<"array"> type;
std::optional<std::string> description;
std::vector<Type> prefixItems;
bool items = false;
};
struct TypedArray {
Literal<"array"> type;
std::optional<std::string> description;
rfl::Ref<Type> items;
};
using ReflectionType = std::variant<AllOf,
AnyOf,
Boolean,
ExclusiveMaximum,
ExclusiveMinimum,
FixedSizeTypedArray,
Integer,
Maximum,
Minimum,
Number,
Null,
Object,
OneOf,
Reference,
Regex,
String,
StringEnum,
StringMap,
Tuple,
TypedArray>;
const auto& reflection() const { return value; }
ReflectionType value;
};
struct Integer {
Literal<"integer"> type;
std::optional<std::string> description;
};
struct Number {
Literal<"number"> type;
std::optional<std::string> description;
};
struct String {
Literal<"string"> type;
std::optional<std::string> description;
};
using NumericType = std::variant<Integer, Number>;
struct AllOf {
std::optional<std::string> description;
std::vector<Type> allOf;
};
struct AnyOf {
std::optional<std::string> description;
std::vector<Type> anyOf;
};
struct ExclusiveMaximum {
std::optional<std::string> description;
std::variant<double, int> exclusiveMaximum;
std::string type;
};
struct ExclusiveMinimum {
std::optional<std::string> description;
std::variant<double, int> exclusiveMinimum;
std::string type;
};
struct FixedSizeTypedArray {
Literal<"array"> type;
std::optional<std::string> description;
rfl::Ref<Type> items;
size_t minContains;
size_t maxContains;
};
struct Maximum {
std::optional<std::string> description;
std::variant<double, int> maximum;
std::string type;
};
struct Minimum {
std::optional<std::string> description;
std::variant<double, int> minimum;
std::string type;
};
struct Null {
Literal<"null"> type;
std::optional<std::string> description;
};
struct Object {
Literal<"object"> type;
std::optional<std::string> description;
std::map<std::string, Type> properties;
std::vector<std::string> required;
};
struct OneOf {
std::optional<std::string> description;
std::vector<Type> oneOf;
};
struct Reference {
Rename<"$ref", std::optional<std::string>> ref;
std::optional<std::string> description;
};
struct Regex {
Literal<"string"> type;
std::optional<std::string> description;
std::string pattern;
};
struct StringEnum {
Literal<"string"> type;
std::optional<std::string> description;
rfl::Rename<"enum", std::vector<std::string>> values;
};
struct StringMap {
Literal<"object"> type;
std::optional<std::string> description;
rfl::Ref<Type> additionalProperties;
};
struct Tuple {
Literal<"array"> type;
std::optional<std::string> description;
std::vector<Type> prefixItems;
bool items = false;
};
struct TypedArray {
Literal<"array"> type;
std::optional<std::string> description;
rfl::Ref<Type> items;
};
using ReflectionType =
std::variant<AllOf, AnyOf, Boolean, ExclusiveMaximum, ExclusiveMinimum,
FixedSizeTypedArray, Integer, Maximum, Minimum, Number, Null,
Object, OneOf, Reference, Regex, String, StringEnum,
StringMap, Tuple, TypedArray>;
const auto& reflection() const { return value; }
ReflectionType value;
};
} // namespace rfl::json::schema
} // namespace rfl::json::schema
#endif