0

Im trying to convert really simple json schema to my c# model using nuget from this link

Im using example code from the github repo such as:

var schema = """{"$schema":"http://json-schema.org/draft-04/schema#","title":"Person","type":"object","additionalProperties":false,"required":["FirstName","LastName"],"properties":{"FirstName":{"type":"string"},"LastName":{"type":"string"}},"definitions":{}}""";
   
var generator = new CSharpGenerator(schema);
var file = generator.GenerateFile("mytest"); // on this line I got an exception
Console.WriteLine(file);
Console.ReadLine();

this is my json schema:

Notice: Im using .net 7 , you can notice that Im using tripple string in order to accept json with double quotes.

Exception that I get:

System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'NJsonSchema.JsonSchema'.'

What I did wrong here?

Stefan0309
  • 1,602
  • 5
  • 23
  • 61
  • Why you don't post your question at this library site? There are already thousands custom json libraries, why we should try every one of them? – Serge Dec 03 '22 at 12:32

0 Answers0