Skip to content

Commit 39761da

Browse files
author
Mario Brizic
committed
Prevent generation of properties marked with JsonIgnore attribute
1 parent 8725010 commit 39761da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/WebApiToTypeScript/Interfaces/InterfaceService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private List<MemberWithCSharpType> GetMembers(TypeDefinition typeDefinition)
334334
});
335335

336336
var properties = typeDefinition.Properties
337-
.Where(p => p.GetMethod != null && p.GetMethod.IsPublic && !p.IsSpecialName)
337+
.Where(p => p.GetMethod != null && p.GetMethod.IsPublic && !p.IsSpecialName && DoesntContainJsonIgnoreAttribute(p))
338338
.Select(p => new MemberWithCSharpType
339339
{
340340
Name = p.Name,
@@ -393,5 +393,11 @@ private InterfaceNode AdjustBaseClass(InterfaceNode interfaceNode, InterfaceNode
393393

394394
return interfaceNode;
395395
}
396+
397+
private bool DoesntContainJsonIgnoreAttribute(PropertyDefinition p)
398+
{
399+
return p.CustomAttributes
400+
.All(a => a.AttributeType.Name != "JsonIgnoreAttribute");
401+
}
396402
}
397403
}

0 commit comments

Comments
 (0)