Skip to content

Commit 6be8c55

Browse files
mmainermmainer
authored andcommitted
Adding fully qualified name for JsonPropertyAttribute Required property. This was conflicting with a property named Required.
1 parent c7a70ec commit 6be8c55

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

Templates/CSharp/Model/ComplexType.cs.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace <#=complex.Namespace.GetNamespaceName()#>
5151
? property.Name.Substring(property.Name.IndexOf('.') + 1).ToCheckedCase()
5252
: property.Name.ToCheckedCase().GetSanitizedPropertyName(property);
5353

54-
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Required.Default)]", property.Name);
54+
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Newtonsoft.Json.Required.Default)]", property.Name);
5555

5656
if (property.IsTypeNullable() || property.IsCollection)
5757
{

Templates/CSharp/Model/EntityType.cs.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace <#=entity.Namespace.GetNamespaceName()#>
6161
var propertyName = property.Name.ToCheckedCase();
6262
var propertyCollectionPage = property.IsReference() ? string.Concat(entityName, propertyName, "CollectionWithReferencesPage") : string.Concat(entityName, propertyName, "CollectionPage");
6363

64-
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Required.Default)]", property.Name);
64+
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Newtonsoft.Json.Required.Default)]", property.Name);
6565

6666
if (property.IsCollection())
6767
{
@@ -109,7 +109,7 @@ namespace <#=entity.Namespace.GetNamespaceName()#>
109109
/// <summary>
110110
/// Gets or sets @odata.type.
111111
/// </summary>
112-
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "@odata.type", Required = Required.Default)]
112+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "@odata.type", Required = Newtonsoft.Json.Required.Default)]
113113
public string ODataType { get; set; }
114114

115115
/// <summary>

Templates/CSharp/Model/MethodRequestBody.cs.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace <#=method.Namespace.GetNamespaceName()#>
4646
}
4747

4848
var paramName = param.Name.ToCheckedCase().GetSanitizedPropertyName();
49-
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Required.Default)]", param.Name);
49+
var attributeDefinition = string.Format("[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = \"{0}\", Required = Newtonsoft.Json.Required.Default)]", param.Name);
5050
#>
5151

5252
/// <summary>

Templates/CSharp/Requests/EntityCollectionResponse.cs.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (prop.Class.Derived != null && prop.Class.Base == null)
3131
/// <summary>
3232
/// Gets or sets the <see cref="I<#=collectionPage#>"/> value.
3333
/// </summary>
34-
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName ="value", Required = Required.Default)]
34+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName ="value", Required = Newtonsoft.Json.Required.Default)]
3535
public I<#=collectionPage#> Value { get; set; }
3636

3737
/// <summary>

Templates/CSharp/Requests/EntityCollectionWithReferencesResponse.cs.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (prop.Class.Derived != null && prop.Class.Base == null)
3131
/// <summary>
3232
/// Gets or sets the <see cref="I<#=collectionPage#>"/> value.
3333
/// </summary>
34-
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName ="value", Required = Required.Default)]
34+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName ="value", Required = Newtonsoft.Json.Required.Default)]
3535
public I<#=collectionPage#> Value { get; set; }
3636

3737
/// <summary>

Templates/CSharp/Requests/MethodCollectionResponse.cs.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace <#=method.Namespace.GetNamespaceName()#>
4444
/// <summary>
4545
/// Gets or sets the <#=propertyName#>.
4646
/// </summary>
47-
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName ="<#=property.Name#>", Required = Required.Default)]
47+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName ="<#=property.Name#>", Required = Newtonsoft.Json.Required.Default)]
4848
public <#=propertyType#> <#=propertyName#> { get; set; }
4949
<#
5050
}

0 commit comments

Comments
 (0)