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

Stackoverflow when using the copy constructor of an OpenApiSchema. #1095

Closed
Sventric opened this issue Dec 3, 2022 · 2 comments · Fixed by #1099
Closed

Stackoverflow when using the copy constructor of an OpenApiSchema. #1095

Sventric opened this issue Dec 3, 2022 · 2 comments · Fixed by #1099
Assignees
Labels
type:bug A broken experience
Milestone

Comments

@Sventric
Copy link

Sventric commented Dec 3, 2022

Using version 1.4.4 of Microsoft.OpenApi.

Describe the bug
When using the copy constructor of OpenApiSchema it comes in a recursive call and end with a stackoverflow exception.

To Reproduce

    OpenApiSchema baseSchema = new OpenApiSchema()
    {
        Type = "string",
        Format = "date"
    };

    OpenApiSchema actualSchema = new OpenApiSchema(baseSchema)
    {
        Nullable = true
    };

The "perpetrator" is the property "AdditionalProperties", this in itself is also a schema but is "copied" with AdditionalProperties = new(schema?.AdditionalProperties); so if null the constructor is again called the original parameter 'schema' and when not null it calls the constructor with AdditionalProperties as a parameter, and this is repeated untill it encounters a null and crashes.

Expected behavior
I expected to get a new OpenApiSchema with the properties from the baseSchema and the explicitly set new properties.

@MaggieKimani1 MaggieKimani1 self-assigned this Dec 6, 2022
@MaggieKimani1 MaggieKimani1 added the type:bug A broken experience label Dec 6, 2022
@MaggieKimani1 MaggieKimani1 added this to the NET: 1.5.0 milestone Dec 6, 2022
@MaggieKimani1
Copy link
Contributor

Thank you for reporting this. This is definitely a bug caused by an oversight on our part.

@MaggieKimani1
Copy link
Contributor

Update: this is now fixed in 1.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants