Skip to content

Commit 979e48f

Browse files
committed
Merge branch 'master' into develop
2 parents f21a44a + 9daab2e commit 979e48f

File tree

10 files changed

+62
-44
lines changed

10 files changed

+62
-44
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
\.vs/
22

33
*.user
4-
.couscous/
4+
.couscous/
5+
docs/Template-Dark/

Template-Dark

Lines changed: 0 additions & 1 deletion
This file was deleted.

couscous.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
template:
22
# Name of the directory containing the website template (default is "website")
3-
# directory: Template-Dark
3+
# directory: docs/Template-Dark
44
# Or if you are using a remote template, you can set the Git URL
55
url: https://github.com/jaredcnance/Template-Dark.git
66
# Name of the index file (default is "README.md")

docs/ContextGraph.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,20 @@ public void ConfigureServices(IServiceCollection services)
3636
If a DbContext is specified when adding the services, the context will be used to define the resources and their names. By default, these names will be hyphenated.
3737

3838
```csharp
39-
// this will be translated into "my-models"
40-
public DbSet<MyModel> MyModels { get; set; }
39+
public class AppDbContext : DbContext {
40+
// this will be translated into "my-models"
41+
public DbSet<MyModel> MyModels { get; set; }
42+
}
4143
```
4244

4345
However, you can specify a custom name like so:
4446

4547
```csharp
46-
// this will be translated into "someModels"
47-
[Resource("someModels")]
48-
public DbSet<MyModel> MyModels { get; set; }
48+
public class AppDbContext : DbContext {
49+
// this will be translated into "someModels"
50+
[Resource("someModels")]
51+
public DbSet<MyModel> MyModels { get; set; }
52+
}
4953
```
5054

5155

docs/Controllers.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ currentMenu: controllers
77
You need to create controllers that inherit from [JsonApiController&lt;TEntity&gt;](https://github.com/Research-Institute/json-api-dotnet-core/blob/master/src/JsonApiDotNetCore/Controllers/JsonApiController.cs).
88

99
```csharp
10-
[Route("api/[controller]")]
1110
public class ThingsController : JsonApiController<Thing>
1211
{
1312
public ThingsController(
@@ -26,7 +25,6 @@ you should explicitly declare it in the controller
2625
and service generic type definitions:
2726

2827
```csharp
29-
[Route("api/[controller]")]
3028
public class ThingsController : JsonApiController<Thing, Guid>
3129
//---------------------- ^^^^
3230
{
@@ -44,7 +42,7 @@ public class ThingsController : JsonApiController<Thing, Guid>
4442

4543
If you need to customize things at the controller level, you can override the virtual
4644
methods. Please be aware that this is not the place for advanced business logic
47-
which should be performed at the [service](resourceServices.html) or [repository](entityRepositories.html) layers. Here is an example override at the controller layer:
45+
which should be performed at the [service](resourceservices.html) or [repository](entityrepositories.html) layers. Here is an example override at the controller layer:
4846

4947
```csharp
5048
public class TodoItemsController : JsonApiController<TodoItem>

docs/EntityRepositories.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ If you want to use EF, but need additional data access logic (such as authorizat
99
methods defined in [DefaultEntityRepository&lt;TEntity, TId&gt;](https://github.com/Research-Institute/json-api-dotnet-core/blob/master/src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs).
1010

1111
The repository should then be
12-
add to the service collection in `Startup.ConfigureServices` like so:
12+
add to the service collection in `Startup.cs` like so:
1313

1414
```csharp
15-
services.AddScoped<IEntityRepository<MyEntity,Guid>, MyAuthorizedEntityRepository>();
15+
public IServiceProvider ConfigureServices(IServiceCollection services) {
16+
services.AddScoped<IEntityRepository<MyEntity,Guid>, MyAuthorizedEntityRepository>();
17+
// ...
18+
}
1619
```
1720

1821
A sample implementation that performs data authorization might look like:

docs/Filtering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public class MyEntityRepository : DefaultEntityRepository<MyEntity>
4343
// use the base filtering method
4444
entities = base.Filter(entities, filterQuery);
4545

46-
// implement custom method
47-
return ApplyMyCustomFilter(entities, filterQuery);
46+
// implement custom method
47+
return ApplyMyCustomFilter(entities, filterQuery);
4848
}
4949
}
5050
```

docs/Installation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ currentMenu: installation
44

55
# Installation
66

7+
- CLI
8+
```
9+
$ dotnet add package jsonapidotnetcore
10+
```
11+
712
- Visual Studio
813
```
914
Install-Package JsonApiDotnetCore
@@ -17,11 +22,6 @@ Install-Package JsonApiDotnetCore
1722
</ItemGroup>
1823
```
1924

20-
- CLI
21-
```
22-
$ dotnet add package jsonapidotnetcore
23-
```
24-
2525
Click [here](https://www.nuget.org/packages/JsonApiDotnetCore/) for the latest NuGet version.
2626

2727
For pre-releases (develop branch), add the [MyGet](https://www.myget.org/feed/Details/research-institute) package feed

docs/Options.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ received with a client generated id. However, this can be allowed by setting the
1111
flag in the options:
1212

1313
```csharp
14-
services.AddJsonApi<AppDbContext>(opt =>
15-
{
16-
opt.AllowClientGeneratedIds = true;
17-
// ..
18-
});
14+
public IServiceProvider ConfigureServices(IServiceCollection services) {
15+
services.AddJsonApi<AppDbContext>(
16+
opt => opt.AllowClientGeneratedIds = true);
17+
// ...
18+
}
1919
```
2020

2121
## Pagination
@@ -24,18 +24,24 @@ If you would like pagination implemented by default, you can specify the page si
2424
when setting up the services:
2525

2626
```csharp
27-
services.AddJsonApi<AppDbContext>(
28-
opt => opt.DefaultPageSize = 10);
27+
public IServiceProvider ConfigureServices(IServiceCollection services) {
28+
services.AddJsonApi<AppDbContext>(
29+
opt => opt.DefaultPageSize = 10);
30+
// ...
31+
}
2932
```
3033

3134
### Total Record Count
3235

3336
The total number of records can be added to the document meta by setting it in the options:
3437

3538
```csharp
36-
services.AddJsonApi<AppDbContext>(opt =>
37-
{
38-
opt.DefaultPageSize = 5;
39-
opt.IncludeTotalRecordCount = true;
40-
});
39+
public IServiceProvider ConfigureServices(IServiceCollection services) {
40+
services.AddJsonApi<AppDbContext>(opt =>
41+
{
42+
opt.DefaultPageSize = 5;
43+
opt.IncludeTotalRecordCount = true;
44+
});
45+
// ...
46+
}
4147
```

docs/Routing.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ currentMenu: routing
66

77
By default the library will configure routes for each controller.
88
Based on the [recommendations](http://jsonapi.org/recommendations/)
9-
outlined in the JSONAPI spec, routes are hyphenated. For example:
9+
outlined in the JSONAPI spec, routes are hyphenated.
1010

11-
```
12-
/todo-items --> TodoItemsController
13-
NOT /todoItems
11+
```http
12+
GET /api/compound-models HTTP/1.1
13+
Accept: application/vnd.api+json
1414
```
1515

1616
## Namespacing and Versioning URLs
1717

1818
You can add a namespace to the URL by specifying it in `ConfigureServices`:
1919

2020
```csharp
21-
services.AddJsonApi<AppDbContext>(
22-
opt => opt.Namespace = "api/v1");
21+
public IServiceProvider ConfigureServices(IServiceCollection services) {
22+
services.AddJsonApi<AppDbContext>(
23+
opt => opt.Namespace = "api/v1");
24+
}
2325
```
2426

2527
## Disable Convention
@@ -30,8 +32,7 @@ by using the `DisableRoutingConvention` Attribute.
3032
```csharp
3133
[Route("[controller]")]
3234
[DisableRoutingConvention]
33-
public class CamelCasedModelsController : JsonApiController<CamelCasedModel>
34-
{
35+
public class CamelCasedModelsController : JsonApiController<CamelCasedModel> {
3536
public CamelCasedModelsController(
3637
IJsonApiContext jsonApiContext,
3738
IResourceService<CamelCasedModel> resourceService,
@@ -46,13 +47,19 @@ as the resource name. This is so that we can build accurrate resource links in t
4647
For example, if you define a resource as `MyModels` the controller route must match:
4748

4849
```csharp
49-
// resource definition
50-
builder.AddResource<TodoItem>("myModels");
50+
public IServiceProvider ConfigureServices(IServiceCollection services) {
51+
services.AddJsonApi(options => {
52+
options.BuildContextGraph((builder) => {
53+
// resource definition
54+
builder.AddResource<TodoItem>("myModels");
55+
});
56+
});
57+
}
5158

5259
// controller definition
5360
[Route("api/myModels")]
5461
[DisableRoutingConvention]
55-
public class TodoItemsController : JsonApiController<TodoItem>
56-
{ //...
62+
public class TodoItemsController : JsonApiController<TodoItem> {
63+
//...
5764
}
5865
```

0 commit comments

Comments
 (0)