RicoSuter / NJsonSchema

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

Increased Json MaxDepth to 128 #1649

Closed johannesmols closed 9 months ago

johannesmols commented 9 months ago

Using NSwag on schemas with large depths causes an exception to be thrown due to the MaxDepth default setting of 64. I am not aware of any way of customizing the Json settings for parsing the schema in a project when using NSwag, as it invokes the precompiled DLL directly. More context here: https://github.com/RicoSuter/NSwag/issues/4394. #1565 is also related, but can be solved by modifying the settings in the project.

I'm not sure if it is the best approach to just change the default setting in this project to solve it. There doesn't seem to be a way of passing in a JsonSerializerSettings object or func to modify it in FromJsonAsync (called from here in NSwag). If there was such an option, the default wouldn't have to be modified here but it could be changed in NSwag where the issue is relevant.

johannesmols commented 9 months ago

Apparently the unit tests are failing due to an old URL in a test, and is not related to this change. I made a new PR to fix this in #1651.

johannesmols commented 9 months ago

Perfect. Perhaps it can then be released with the upcoming v11.

johannesmols commented 9 months ago

@lahma Any chance of merging this? I'm still having the issue of not being able to generate clients with NSwag, and it would be nice to have it included in a future release to resolve this.

lahma commented 9 months ago

We are waiting for Rico as he does the final call...

RicoSuter commented 9 months ago

I think this is fine... we should not expose Newtonsoft.Json serializer internals as eventually NJS and NSwag will switch to STJ for schema serialization and this option would then go away anyway.