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

Support [DataMember] IsRequired in NewtonsoftDataContractResolver #2644

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ouvreboite
Copy link

@ouvreboite ouvreboite commented May 3, 2023

cf #2383

  • Add non-regression tests to ensure [DataMember(IsRequired)] do not bypass existing [JsonObject], [JsonProperty] or [JsonRequired] attributes.
  • Add tests for [DataMember(IsRequired)] and [DataMember(name)]
  • Update NewtonsoftDataContractResolver to directly leverage jsonProperty.Required, instead of using the IsRequiredSpecifed extension method
  • Move tests to net7 to fix CI

As DataMember implementation comes after the implementation for [JsonProperty] and [JsonObject], we want to be sure that the current behavior is not bypassed.
Add test cases for DataMember (IsRequired and Name).
It seems that NewtonSoft's ResolveContract correctly set the Required, using [DataMember], [JsonProperpty] and [JsonRequired] so we can directly use it instead of the IsRequiredSpecifed extension method.
Havunen added a commit to Havunen/DotSwashbuckle2 that referenced this pull request Feb 12, 2024
Havunen added a commit to Havunen/DotSwashbuckle that referenced this pull request Feb 18, 2024
@martincostello
Copy link
Collaborator

Thanks for contributing - if you'd like to continue with this pull request, please rebase against the default branch to pick up our new CI. We'd also require tests for this scenario.

@ouvreboite
Copy link
Author

I'll rebase once #2799 is merged

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.

None yet

2 participants