Skip to content

Commit 24b8eef

Browse files
authored
Merge pull request #128 from neuroglia-io/fix-yamldotnet-jsonschema-serialization
Fix the `JsonSchemaTypeConverter` to convert `Json.Schema.JsonSchema` instances, instead of YamlDotNet ones
2 parents 8777ee2 + b9c4676 commit 24b8eef

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Neuroglia.Serialization.YamlDotNet/Services/JsonSchemaTypeConverter.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
using Json.Schema;
1415
using System.Text.Json.Nodes;
1516
using YamlDotNet.Core;
1617
using YamlDotNet.Serialization;
17-
using YamlDotNet.Serialization.Schemas;
1818

1919
namespace Neuroglia.Serialization.Yaml;
2020

@@ -34,8 +34,7 @@ public class JsonSchemaTypeConverter
3434
/// <inheritdoc/>
3535
public virtual void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer rootSerializer)
3636
{
37-
var schema = value as JsonSchema;
38-
if (schema == null) return;
37+
if (value is not JsonSchema schema) return;
3938
var node = Json.JsonSerializer.Default.Deserialize<JsonObject>(Json.JsonSerializer.Default.SerializeToText(schema));
4039
new JsonNodeTypeConverter().WriteYaml(emitter, node, type, rootSerializer);
4140
}

0 commit comments

Comments
 (0)