-
Notifications
You must be signed in to change notification settings - Fork 199
StackOverflow Exception on circular reference #54
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
Comments
@Frankyfrankly Thanks for the issue. I looked at the issue, but if you change the models' structure it will solve your issue: public class Book
{
...
public string AuthorId { get; set; }
}
public class Author
{
...
public List<Book> Books { get; set; }
} To me, the circular reference issue is about how data structure looks like, rather than the issue of this extension. If you still want to keep the public class Book
{
...
public string AuthorId { get; set; }
[OpenApiIgnore()]
public Author Author { get; set; }
} By doing so, you will avoid the circular reference issue. |
@Frankyfrankly I'll close the issue for now. If you'd like to discuss more on this, please open a new issue. |
Related to: aliencube/AzureFunctions.Extensions#134 |
Hi @justinyoo , I run into same problem as is described aliencube/AzureFunctions.Extensions#134 |
This is not working for me as OpenApiIgnoreAttibute seems to only be valid for |
@john-patterson Oops my bad. I meant |
@justinyoo ah. Okay, yeah I see in the code where that gets selected out. Unfortunately Is there opposition to a PR that generalizes If this works from a product management perspective, I can get a PR thrown together later today. |
@vlaskal Thanks for your suggestion! What I'm suspecting where the StackOverflowException or CircularReferenceException occurs is these two parts: Lines 208 to 216 in 626d2bd
Adding the reference schemas should also be done before traversing each type's properties. Lines 97 to 109 in 626d2bd
It would be great if you can have a look. Once it's fixed, @john-patterson you wouldn't need to extend the |
@justinyoo Thanks for hints. I will try too look at it and will reach you back. |
I have the same issue and a possible solution in #467 |
I'm also getting this error without any luck using the |
This issue still exists, and I’m wondering why we can't configure the serialization depth in the OpenAPI configuration. Neither changing the model nor using JsonIgnore is a good solution, since in the API, based on the endpoint the consumer is calling, I want to have one or two layers of depth — but not more. For example, when the consumer calls get-book, the API should expose the author of the book but stop there and not include the books of the author. When the consumer calls get-author, the API should expose the books of the author but not the author of those books. |
Uh oh!
There was an error while loading. Please reload this page.
Here is a code sample to reproduce the issue:
It seems like recursion happens in Visit method of ObjectTypeVisitor class.
The same can be reproduced in Microsoft.Azure.WebJobs.Extensions.OpenApi.FunctionApp.V3IoC project by adding a new class Owner:
And introducing new property "public Owner Owner { get; set; }" in Pet class
The text was updated successfully, but these errors were encountered: