File tree Expand file tree Collapse file tree 3 files changed +356
-348
lines changed
test/UnitTests/Controllers Expand file tree Collapse file tree 3 files changed +356
-348
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ public static ErrorCollection ConvertToErrorCollection<T>(this ModelStateDiction
1414 if ( entry . Value . Errors . Any ( ) == false )
1515 continue ;
1616
17+ var attrName = contextGraph . GetPublicAttributeName < T > ( entry . Key ) ;
18+
1719 foreach ( var modelError in entry . Value . Errors )
1820 {
19- var attrName = contextGraph . GetPublicAttributeName < T > ( entry . Key ) ;
20-
2121 if ( modelError . Exception is JsonApiException jex )
2222 collection . Errors . AddRange ( jex . GetError ( ) . Errors ) ;
2323 else
@@ -26,7 +26,7 @@ public static ErrorCollection ConvertToErrorCollection<T>(this ModelStateDiction
2626 title : entry . Key ,
2727 detail : modelError . ErrorMessage ,
2828 meta : modelError . Exception != null ? ErrorMeta . FromException ( modelError . Exception ) : null ,
29- source : new {
29+ source : attrName == null ? null : new {
3030 pointer = $ "/data/attributes/{ attrName } "
3131 } ) ) ;
3232 }
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ public string GetPublicAttributeName<TParent>(string internalAttributeName)
122122 {
123123 return GetContextEntity ( typeof ( TParent ) )
124124 . Attributes
125- . Single ( a => a . InternalAttributeName == internalAttributeName )
125+ . SingleOrDefault ( a => a . InternalAttributeName == internalAttributeName ) ?
126126 . PublicAttributeName ;
127127 }
128128 }
You can’t perform that action at this time.
0 commit comments