RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.4k stars 535 forks source link

NJsonSchema is not producing valid C# #1529

Open spierepf opened 2 years ago

spierepf commented 2 years ago

When I generate C# from either of the attached json schema files

position_schema.json.txt flightplan_schema.json.txt

the resulting C# gives me several ambiguity errors around _additionalProperties. I'm not sure why these entries are being generated.

I've tried adding additonalProperties:false to the schema as suggested in https://www.thecodebuzz.com/csharp-class-json-schema/comment-page-1/#comment-12531

And even added:

    schemaFromFile.AllowAdditionalProperties = false;
    foreach (var schema in schemaFromFile.AllInheritedSchemas)
    {
        schema.AllowAdditionalProperties = false;
    }

to my code. But no matter what I do I'm getting these entries, and the resulting code does not compile...