You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`AllowedIncludesAttribute`: Restricts which relationships can be included in responses
78
+
79
+
6.**Validation** (`Validation/`)
80
+
-`IncludePatternValidator`: Validates include patterns with wildcard support
81
+
76
82
### Key Patterns
77
83
78
84
-**Convention-based mapping**: Properties are automatically mapped from C# PascalCase to JSON camelCase
@@ -82,6 +88,7 @@ Documentation is built using DocFX and deployed to GitHub Pages. The documentati
82
88
-**Filter expressions**: Complex filtering with operators (eq, ne, gt, lt, contains, etc.), logical grouping, and enum support
83
89
-**JSON column detection**: Collections and complex objects without ID properties are automatically mapped as JSON attributes instead of relationships (useful for EF Core owned entities stored as JSON columns)
84
90
-**Pagination safety**: Invalid page numbers are automatically clamped to valid ranges (page 1 for negative/zero, last page for overflow)
91
+
-**Include whitelisting**: Use `AllowedIncludesAttribute` on controller actions to restrict which relationships can be included, preventing unauthorized data exposure
85
92
86
93
### Service Registration
87
94
@@ -124,12 +131,14 @@ Tests are organized by component:
124
131
125
132
1.**Query Operations**: Extend `FilterExpressionBuilder` and add corresponding operators to `FilterOperator` enum
126
133
2.**New Controllers**: Inherit from `JsonApiController` and use provided helper methods
127
-
3.**Entity Mapping**: Use `EntityMapper` for custom mapping rules and automatic detection of relationships vs attributes
134
+
3.**Entity Mapping**: Use `EntityMapper` for automatic detection of relationships vs attributes based on ID properties
128
135
4.**Testing**: Follow existing patterns with xUnit and Moq, test both success and error scenarios
129
136
130
137
### Common Patterns
131
138
132
-
- Controllers should inherit from `JsonApiController` and use `JsonApiOkAsync(queryable, "resourceType")`
139
+
- Controllers should inherit from `JsonApiController`
140
+
- Use `JsonApiOkAsync(queryable, "resourceType")` for collections with full query processing
141
+
- Use `JsonApiOk(entity, "resourceType")` for already-loaded entities or collections
133
142
- Entity types should have an `Id` property (auto-detected by `EntityMapper.GetIdProperty()`)
134
143
- Use `QueryParameters queryParams = GetJsonApiQueryParameters()` to access parsed query parameters
135
144
- For manual mapping, use `JsonApiMapper.ToDocument()` or `ToCollectionDocument()`
0 commit comments