-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨Add support for [DataMember(IsRequired)]
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.
- Loading branch information
1 parent
c6a4075
commit 119be8c
Showing
4 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/DataMemberAnnotatedType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Swashbuckle.AspNetCore.Newtonsoft.Test | ||
{ | ||
[DataContract(Name = "CustomNameFromDataContract")] | ||
public class DataMemberAnnotatedType | ||
{ | ||
[DataMember(IsRequired = true)] | ||
public string StringWithDataMemberRequired { get; set; } | ||
|
||
[DataMember(IsRequired = false)] | ||
public string StringWithDataMemberNonRequired { get; set; } | ||
|
||
[DataMember(IsRequired = true, Name = "RequiredWithCustomNameFromDataMember")] | ||
public string StringWithDataMemberRequiredWithCustomName { get; set; } | ||
|
||
[DataMember(IsRequired = false, Name = "NonRequiredWithCustomNameFromDataMember")] | ||
public string StringWithDataMemberNonRequiredWithCustomName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters