Skip to content
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

List of Recursive Models #156

Closed
RGBKnights opened this issue Jun 30, 2021 · 10 comments · Fixed by #233
Closed

List of Recursive Models #156

RGBKnights opened this issue Jun 30, 2021 · 10 comments · Fixed by #233
Assignees
Labels
bug Something isn't working investigating Need time to investigating oca-issue For participants from OSS Contribution Academy

Comments

@RGBKnights
Copy link

RGBKnights commented Jun 30, 2021

I have a Field class that list columns that is also a Field.

public class Field 
{
    public Guid Id { get; set; } 
    public string Name { get; set; }
    public string Type { get; set; }
    public List<Field> Columns { get; set; }
}

Everything I know about the OpenAPI spec tells me this should be possible but the whole application crashes trying to render the swagger UI with a System.StackOverflowException.

@Skovvart
Copy link

Skovvart commented Jul 8, 2021

I am experiencing the same issue. Some more details:

My minimally reproducible model:

    public class Category
    {
        public IList<Category> Children { get; set; }
    }

Error occurs when requesting the swagger.json file

swagger.json was requested.
Stack overflow.

Workaround (-ish):
Changing
[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(Category), Example = typeof(CategoryExample))]
to
[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(object), Example = typeof(CategoryExample))]

Though it now obviously does not expose the actual model.

@Skovvart
Copy link

Skovvart commented Jul 12, 2021

The issue may be related to #54

@jpshilton
Copy link

Any movement on this? I'm seeing the same issue with a recursive data type even when the property is set to null in my OpenApiExample type.

  public class CategoryGetManyExample : OpenApiExample<CategoryModel>
    {
        public override IOpenApiExample<CategoryModel> Build(NamingStrategy namingStrategy = null)
        {
            Examples.Add(OpenApiExampleResolver.Resolve("Exmaple Category", new CategoryModel { Name = "Category", Subcategories = null }, namingStrategy));

            return this;
        }
    }

@level120
Copy link
Contributor

I think this issue related to #167

@github-actions github-actions bot added the oca-issue For participants from OSS Contribution Academy label Aug 27, 2021
@justinyoo
Copy link
Contributor

@level120 Not really. Recursive error is a separate issue.

@sebb3
Copy link

sebb3 commented Sep 7, 2021

I have the same issue. I looked at the PR (#138 ) solving #54 and the fix that was made does not check for IEnumerable of Type.

Could that be a possible solution @justinyoo?

@choipureum
Copy link
Contributor

choipureum commented Sep 8, 2021

Can I look for a solution?

Considering the existence of recursive visitors, it does not seem to work in the form of a data structure including recursive.

@justinyoo
Copy link
Contributor

@choipureum Sure. I'll assign it to you.

@justinyoo justinyoo added bug Something isn't working working investigating Need time to investigating and removed working labels Sep 8, 2021
@tsolbjor
Copy link
Contributor

tsolbjor commented Sep 8, 2021

I have the same issue and a possible solution in #233

@justinyoo justinyoo linked a pull request Sep 14, 2021 that will close this issue
meanstigerkim pushed a commit to meanstigerkim/azure-functions-openapi-extension that referenced this issue Oct 5, 2021
@decocsa
Copy link

decocsa commented Oct 13, 2021

Should this be fixed in Feature/#156? I still have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigating Need time to investigating oca-issue For participants from OSS Contribution Academy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants