@@ -263,7 +263,7 @@ schema::Type type_to_json_schema_type(const parsing::schema::Type& _type,
263263
264264 } else if constexpr (std::is_same<T, Type::Reference>()) {
265265 return schema::Type{
266- .value = schema::Type::Reference{.ref = " #/definitions /" + _t.name_ }};
266+ .value = schema::Type::Reference{.ref = " #/$defs /" + _t.name_ }};
267267
268268 } else if constexpr (std::is_same<T, Type::StringMap>()) {
269269 return schema::Type{
@@ -297,7 +297,8 @@ schema::Type type_to_json_schema_type(const parsing::schema::Type& _type,
297297
298298std::string to_schema_internal_schema (
299299 const parsing::schema::Definition& internal_schema,
300- const yyjson_write_flag _flag, const bool _no_required) {
300+ const yyjson_write_flag _flag, const bool _no_required,
301+ std::string comment) {
301302 auto definitions = std::map<std::string, schema::Type>();
302303 for (const auto & [k, v] : internal_schema.definitions_ ) {
303304 definitions[k] = type_to_json_schema_type (v, _no_required);
@@ -306,8 +307,11 @@ std::string to_schema_internal_schema(
306307 typename TypeHelper<schema::Type::ReflectionType>::JSONSchemaType;
307308 const auto to_schema = [&](auto && _root) -> JSONSchemaType {
308309 using U = std::decay_t <decltype (_root)>;
309- return schema::JSONSchema<U>{.root = std::move (_root),
310- .definitions = definitions};
310+ return schema::JSONSchema<U>{
311+ .comment = comment.size () ? std::optional (comment) : std::nullopt ,
312+ .root = std::forward<decltype (_root)>(_root),
313+ .definitions = definitions,
314+ };
311315 };
312316 auto root = type_to_json_schema_type (internal_schema.root_ , _no_required);
313317 const auto json_schema = rfl::visit (to_schema, std::move (root.value ));
0 commit comments