9#include <unordered_map>
10#include <unordered_set>
14#include <userver/formats/yaml_fwd.hpp>
16USERVER_NAMESPACE_BEGIN
31std::string ToString(FieldType type);
33class SchemaPtr
final {
35 explicit SchemaPtr(Schema&& schema);
37 SchemaPtr(SchemaPtr&&)
noexcept =
default;
38 SchemaPtr& operator=(SchemaPtr&&)
noexcept =
default;
39 SchemaPtr(
const SchemaPtr&);
40 SchemaPtr& operator=(
const SchemaPtr&);
42 const Schema& operator*()
const;
44 const Schema* operator->()
const {
return &**
this; }
45 Schema* operator->() {
return &**
this; }
47 bool operator==(
const SchemaPtr&)
const;
50 std::unique_ptr<Schema> schema_;
53formats::
yaml::Value Serialize(
const SchemaPtr& schema, formats::
serialize::
To<formats::
yaml::Value>);
61 void UpdateDescription(std::string new_description);
63 static Schema EmptyObject();
65 bool operator==(
const Schema&)
const;
70 std::string description;
71 std::optional<std::string> default_description;
72 std::optional<std::variant<
bool, SchemaPtr>> additional_properties;
73 std::optional<std::unordered_map<std::string, SchemaPtr>> properties;
74 std::optional<SchemaPtr> items;
75 std::optional<std::unordered_set<std::string>> enum_values;
76 std::optional<
double> minimum;
77 std::optional<
double> maximum;
78 std::optional<std::size_t> min_items;
79 std::optional<std::size_t> max_items;
82Schema Parse(
const formats::
yaml::Value& schema, formats::
parse::
To<Schema>);
84formats::
yaml::Value Serialize(
const Schema& schema, formats::
serialize::
To<formats::
yaml::Value>);
88Schema SchemaFromString(
const std::string& yaml_string);