Skip to content

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

Development

Successfully merging this pull request may close these issues.

Append Format property value to root schema when serializing as v2 if contained in anyOf, allOf, oneOf of child schemas

3 participants