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

Appends format property value to root schema if contained in anyOf, oneOf or allOf when serializing as v2 #1001

Merged
merged 5 commits into from
Sep 7, 2022

Conversation

irvinesunday
Copy link
Contributor

Fixes #992

This PR:

  • Retrieves the format property value from the child schemas of anyOf, oneOf or allOf and appends this to the root schema when serializing as v2 (when writing items as properties).
  • Updates test to validate the above.

Comment on lines 569 to 571
Format ??= AllOf?.FirstOrDefault(static x => x.Format != null)?.Format ??
AnyOf?.FirstOrDefault(static x => x.Format != null)?.Format ??
OneOf?.FirstOrDefault(static x => x.Format != null)?.Format;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not super familiar with the code base here. But shouldn't this have a condition to only do it when we are serializing to v2?

Also, the conditions should be string.IsNullOrEmpty, not just a null comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is only called by methods that serialize as v2

Copy link
Member

Choose a reason for hiding this comment

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

thanks for the precision. for the string is null or empty comment, I was also referring to the lambdas

@baywet
Copy link
Member

baywet commented Sep 7, 2022

also we should probably bump the preview version to we can use it in the conversion lib PR

@irvinesunday irvinesunday merged commit 6ff3176 into vnext Sep 7, 2022
@irvinesunday irvinesunday deleted the fix/is/format-prop-params branch September 7, 2022 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants