-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swagger API docs generation: Error: Max. depth level of JSON reached at position #10393
Comments
Reported error seems to be reported by Jint JavaScript interpreter.
By default Is it able to provide |
From what I can see in the raw model json the maximum depth is 21 (42 spaces) when it fails in one occasion, another time it is 15 (30 spaces). The parsing stops in the middle of the line within the spaces, it doesn't even make it to the properties, like this:
|
I've created minimum projects that can reproduce problems. Is it able to test required Program.cs using Jint;
const int maxDepth = 64;
var data = File.ReadAllText(@"C:\Temp\swagger.json");
var engine = new Engine(options =>
{
options.Json.MaxParseDepth = maxDepth;
})
.SetValue("data", data);
var text = "return JSON.stringify(JSON.parse(data))";
var result = engine.Evaluate(text).AsString();
Console.WriteLine("Parse operation is successfully completed."); Issue_10393.csproj <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jint" Version="4.1.0" />
</ItemGroup>
</Project>
|
I will try to do so when I am back, currently out of office. Thanks for the repro details! |
Alright, the issue does not occur with the provided Program.cs. However, using the same swagger.json causes the exception in docfx:
It again happens randomly in the line, not at a certain property. On another occasion it was in the middle of a property name. To me it doesn't make any sense why it would fail on one occasion and not on the other. I am not able to provide a minimal reproduction swagger.json until at earliest in a week, again out of office, though it will most likely not be easy to make one with just dummy classes. |
Describe the issue
I am facing an issue that when having a really large swagger.json (15+ thousand lines, size was 7.538 MB), the json stringify or parse function will fail with the error message
Error: Max. depth level of JSON reached at position xxx
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
docfx is able to parse the swagger.json without issues.
Context (please complete the following information):
Additional context
A swagger.json with around 10k lines doesn't fail. The issue seems to be caused by an underlying JS library that has the limit, but I am not a specialist there to be able to tell what exactly is going on. I am not able to share the swagger.json due to NDA. Full stacktrace:
The text was updated successfully, but these errors were encountered: