@@ -18,7 +18,7 @@ For pre-releases, add the [MyGet](https://www.myget.org/feed/Details/research-in
18
18
(https://www.myget.org/F/research-institute/api/v3/index.json )
19
19
to your nuget configuration.
20
20
21
- # Generators
21
+ ## Generators
22
22
23
23
You can install the [ Yeoman generators] ( https://github.com/Research-Institute/json-api-dotnet-core-generators )
24
24
to make building applications much easier.
@@ -34,7 +34,7 @@ You need to do 3 things:
34
34
I recommend reading the details below, but once you're familiar with the
35
35
setup, you can use the Yeoman generator to generate the required classes.
36
36
37
- ## Middleware and Services
37
+ ### Middleware and Services
38
38
39
39
Add the following to your ` Startup.ConfigureServices ` method.
40
40
Replace ` AppDbContext ` with your DbContext.
@@ -51,7 +51,7 @@ so there is no need to add that as well.
51
51
app .UseJsonApi ();
52
52
```
53
53
54
- ## Defining Models
54
+ ### Defining Models
55
55
56
56
Your models should inherit ` Identifiable<TId> ` where ` TId ` is the type of the primary key, like so:
57
57
@@ -62,7 +62,7 @@ public class Person : Identifiable<Guid>
62
62
}
63
63
```
64
64
65
- ### Specifying Public Attributes
65
+ #### Specifying Public Attributes
66
66
67
67
If you want an attribute on your model to be publicly available,
68
68
add the ` AttrAttribute ` and provide the outbound name.
@@ -77,7 +77,7 @@ public class Person : Identifiable<int>
77
77
}
78
78
```
79
79
80
- ### Relationships
80
+ #### Relationships
81
81
82
82
In order for navigation properties to be identified in the model,
83
83
they should be labeled as virtual.
@@ -110,7 +110,7 @@ public class TodoItem : Identifiable<int>
110
110
}
111
111
```
112
112
113
- ## Defining Controllers
113
+ ### Defining Controllers
114
114
115
115
You need to create controllers that inherit from ` JsonApiController<TEntity> ` or ` JsonApiController<TEntity, TId> `
116
116
where ` TEntity ` is the model that inherits from ` Identifiable<TId> ` .
@@ -128,7 +128,7 @@ public class ThingsController : JsonApiController<Thing>
128
128
}
129
129
```
130
130
131
- ### Non-Integer Type Keys
131
+ #### Non-Integer Type Keys
132
132
133
133
If your model is using a type other than ` int ` for the primary key,
134
134
you should explicitly declare it in the controller
@@ -147,7 +147,7 @@ public class ThingsController : JsonApiController<Thing, Guid>
147
147
}
148
148
```
149
149
150
- ## Routing
150
+ ### Routing
151
151
152
152
By default the library will configure routes for each controller.
153
153
Based on the [ recommendations] ( http://jsonapi.org/recommendations/ )
@@ -158,7 +158,7 @@ outlined in the JSONAPI spec, routes are hyphenated. For example:
158
158
NOT /todoItems
159
159
```
160
160
161
- ### Namespacing and Versioning URLs
161
+ #### Namespacing and Versioning URLs
162
162
163
163
You can add a namespace to the URL by specifying it in ` ConfigureServices ` :
164
164
@@ -167,7 +167,7 @@ services.AddJsonApi<AppDbContext>(
167
167
opt => opt .Namespace = " api/v1" );
168
168
```
169
169
170
- ## Defining Custom Data Access Methods
170
+ ### Defining Custom Data Access Methods
171
171
172
172
You can implement custom methods for accessing the data by creating an implementation of
173
173
` IEntityRepository<TEntity, TId> ` . If you only need minor changes you can override the
@@ -205,7 +205,7 @@ public class MyAuthorizedEntityRepository : DefaultEntityRepository<MyEntity>
205
205
}
206
206
```
207
207
208
- ## Pagination
208
+ ### Pagination
209
209
210
210
Resources can be paginated.
211
211
The following query would set the page size to 10 and get page 2.
@@ -222,7 +222,7 @@ when setting up the services:
222
222
opt => opt .DefaultPageSize = 10 );
223
223
```
224
224
225
- ## Filtering
225
+ ### Filtering
226
226
227
227
You can filter resources by attributes using the ` filter ` query parameter.
228
228
By default, all attributes are filterable.
@@ -243,7 +243,7 @@ identifier):
243
243
?filter[attribute]=ge:value
244
244
```
245
245
246
- ## Sorting
246
+ ### Sorting
247
247
248
248
Resources can be sorted by an attribute:
249
249
@@ -252,9 +252,7 @@ Resources can be sorted by an attribute:
252
252
?sort=-attribute // descending
253
253
```
254
254
255
- # Tests
256
-
257
- ## Running
255
+ ## Tests
258
256
259
257
I am using DotNetCoreDocs to generate sample requests and documentation.
260
258
0 commit comments