StackOverflow when using SchemaRegistry.GetOrRegister in ISchemaFiler.Apply
See original GitHub issueHi,
I’ve got a StackOverflow while using a ISchemaFilter that need to register a new type. The recursion happens because I’m applying the filter to a referenced type, not a top-level type. During the while loop of GetOrRegister, my filter get’s called for type A in which I call GetOrRegister for type B. This loops again on the ‘not-yet-compiled’ types and A it’s still there … and calls again my filter on the A type.
You can reproduce with an endpoint that takes this type as ([FromBody]Command c) signature.
public class Command
{
public int A {get ;set; }
public Data Data {get;set;}
}
public class Data
{
public int A {get;set;}
public int B {get;set;}
public IDictionary<object, object> ComplexFieldForWhichIWantToBuildSchema {get;set;}
}
public Filter : ISchemaFilter
{
public void Apply(Schema schema, SchemaRegistry schemaRegistry, Type type)
{
if (type == typeof(Data))
{
var t = typeof(KeyValuePair<string, string>[]);
schema.properties["ComplexFieldForWhichIWantToBuildSchema"] = schemaRegistry.GetOrRegister(t);
}
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
StackOverflow when using SchemaRegistry.GetOrRegister ...
I've got a StackOverflow while using a ISchemaFilter that need to register a new type. The recursion happens because I'm applying the filter...
Read more >Using Swashbuckle for Asp.net core how can I add a ...
This allows you to apply [ApiExplorerSettings(GroupName = "my_group")] attributes to the manually mapped classes (models, schemas) to s them ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m still seeing this issue in release 5.5.3. In my case I’m attempting to register a previously unregistered type, which might be different from the scenario in the test added in #890. Looks like it is attempting to re-run the SchemaFilters on the same type over & over which is causing the stack overflow exception.
See PR #890 which resolves this. Will be available with the upcoming v5.5.0 release