9#include <unordered_map>
10#include <unordered_set>
14#include <userver/formats/parse/common_containers.hpp>
15#include <userver/formats/yaml_fwd.hpp>
17USERVER_NAMESPACE_BEGIN
32std::string ToString(FieldType type);
34class SchemaPtr
final {
36 explicit SchemaPtr(Schema&& schema);
38 const Schema& operator*()
const {
return *schema_; }
39 Schema& operator*() {
return *schema_; }
41 const Schema* operator->()
const {
return schema_.get(); }
44 std::unique_ptr<Schema> schema_;
47formats::
yaml::Value Serialize(
const SchemaPtr& schema,
56 void UpdateDescription(std::string new_description);
58 static Schema EmptyObject();
63 std::string description;
64 std::optional<std::string> default_description;
65 std::optional<std::variant<
bool, SchemaPtr>> additional_properties;
66 std::optional<std::unordered_map<std::string, SchemaPtr>> properties;
67 std::optional<SchemaPtr> items;
68 std::optional<std::unordered_set<std::string>> enum_values;
69 std::optional<
double> minimum;
70 std::optional<
double> maximum;
71 std::optional<size_t> min_items;
72 std::optional<size_t> max_items;
75Schema Parse(
const formats::
yaml::Value& schema, formats::
parse::
To<Schema>);
77formats::
yaml::Value Serialize(
const Schema& schema,
82Schema SchemaFromString(
const std::string& yaml_string);