101 return schema_name<typename T::value_type>();
105 if constexpr (std::is_same_v<T, std::vector<uint8_t>>)
108 return "base64string";
112 return fmt::format(
"{}_array", schema_name<typename T::value_type>());
119 return fmt::format(
"{}_set", schema_name<typename T::value_type>());
127 schema_name<typename T::key_type>(),
128 schema_name<typename T::mapped_type>());
134 schema_name<typename T::first_type>(),
135 schema_name<typename T::second_type>());
137 else if constexpr (std::is_same_v<T, std::string>)
141 else if constexpr (std::is_same_v<T, bool>)
145 else if constexpr (std::is_same_v<T, uint8_t>)
149 else if constexpr (std::is_same_v<T, uint16_t>)
153 else if constexpr (std::is_same_v<T, uint32_t>)
157 else if constexpr (std::is_same_v<T, uint64_t>)
161 else if constexpr (std::is_same_v<T, int8_t>)
165 else if constexpr (std::is_same_v<T, int16_t>)
169 else if constexpr (std::is_same_v<T, int32_t>)
173 else if constexpr (std::is_same_v<T, int64_t>)
177 else if constexpr (std::is_same_v<T, float>)
181 else if constexpr (std::is_same_v<T, double>)
185 else if constexpr (std::is_same_v<T, nlohmann::json>)
189 else if constexpr (std::is_same_v<T, JsonSchema>)
191 return "json_schema";
195 return adl::schema_name<T>();
204 fill_schema<typename T::value_type>(schema);
211 if constexpr (std::is_same_v<T, std::vector<uint8_t>>)
214 schema[
"type"] =
"string";
215 schema[
"format"] =
"base64";
219 schema[
"type"] =
"array";
220 schema[
"items"] = schema_element<typename T::value_type>();
230 if constexpr (nlohmann::detail::
231 is_compatible_object_type<nlohmann::json, T>::value)
233 schema[
"type"] =
"object";
234 schema[
"additionalProperties"] =
235 schema_element<typename T::mapped_type>();
239 schema[
"type"] =
"array";
240 auto items = nlohmann::json::object();
242 items[
"type"] =
"array";
244 auto sub_items = nlohmann::json::array();
245 sub_items.push_back(schema_element<typename T::key_type>());
246 sub_items.push_back(schema_element<typename T::mapped_type>());
247 items[
"items"] = sub_items;
249 schema[
"items"] = items;
254 schema[
"type"] =
"array";
255 auto items = nlohmann::json::array();
256 items.push_back(schema_element<typename T::first_type>());
257 items.push_back(schema_element<typename T::second_type>());
258 schema[
"items"] = items;
260 else if constexpr (std::is_same_v<T, std::string>)
262 schema[
"type"] =
"string";
264 else if constexpr (std::is_same_v<T, bool>)
266 schema[
"type"] =
"boolean";
268 else if constexpr (std::is_same_v<T, nlohmann::json>)
272 schema = nlohmann::json::object();
274 else if constexpr (std::is_integral_v<T>)
276 fill_number_schema<T>(schema);
278 else if constexpr (std::is_floating_point_v<T>)
280 schema[
"type"] =
"number";
282 else if constexpr (std::is_same_v<T, JsonSchema>)
284 schema[
"type"] =
"object";
288 adl::fill_schema<T>(schema);