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

Discriminator - Ensure warning shows up in recursive case #4350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gadcam
Copy link

@gadcam gadcam commented Mar 19, 2024

Traverse paths until exhaustion of the tree before checking if a discriminator is needed.
With the previous code the example added in the test where we have a oneOf hidden inside an array would be enough to confuse the check.

@gadcam gadcam requested a review from a team as a code owner March 19, 2024 00:01
@gadcam
Copy link
Author

gadcam commented Mar 19, 2024

@microsoft-github-policy-service agree

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution.
I do think we'll need to make a few tweaks before we can merge this.
Also, can you add an entry to the changelog please? (unreleased, changed)

@@ -68,6 +72,12 @@ public static bool IsObject(this OpenApiSchema? schema)
{
return "object".Equals(schema?.Type, StringComparison.OrdinalIgnoreCase);
}

public static bool IsScalar(this OpenApiSchema? schema)
Copy link
Member

Choose a reason for hiding this comment

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

this method name is confusing. An array would technically return true even though semantically it's not scalar.

Also the implementation checks two separate concerns: the structure (object) and the location (reference) of the schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress 🚧
Development

Successfully merging this pull request may close these issues.

2 participants