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

Fix isNotRecurringNestStruct function #241

Merged
merged 1 commit into from
Nov 9, 2018

Conversation

nkly
Copy link
Contributor

@nkly nkly commented Nov 6, 2018

Currently, the function does not use its refTypeName parameter; instead it checks that the 1st structure in the structures stack does not repeat. Recursion, however, can be indirect. Consider the
following example:

type Foo struct {
    Bar Bar
}

type Bar struct {
    Foo Foo
}

type Baz struct {
    Foo Foo
}

In the example generator will crash with stack overflow while trying to generate spec for Baz when there is no spec for Foo and Bar generated yet.

The fix is to check that refTypeName does not repeat in the structures stack.

@nkly nkly force-pushed the fix-nesting-struct-test branch from 160459f to b405587 Compare November 6, 2018 14:14
Currently, the function does not use its refTypeName parameter;
instead it checks that the 1st structure in the structures stack
does not repeat. Recursion, however, can be indirect. Consider the
following example:

    type Foo struct {
        Bar Bar
    }

    type Bar struct {
        Foo Foo
    }

    type Baz struct {
        Foo Foo
    }

In the example generator will crash with stack overflow while trying to
generate spec for Baz when there is no spec for Foo and Bar generated
yet.

The fix is to check that refTypeName does not repeat in the structures
stack.
@nkly nkly force-pushed the fix-nesting-struct-test branch from b405587 to fd49f74 Compare November 7, 2018 09:49
Copy link
Member

@easonlin404 easonlin404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@easonlin404 easonlin404 merged commit 8f09470 into swaggo:master Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants