Skip to content

Commit 61e75c5

Browse files
committed
update readme
1 parent 91f29c1 commit 61e75c5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ app.UseJsonApi();
2727

2828
## Specifying The Presenter / ViewModel
2929

30-
When you define a model, you **must** specify the associated `JsonApiResource` class which **must** implement `IJsonApiResource`.
31-
This is used for mapping out only the data that should be available to client applications.
30+
- When you define a model, you **MUST** specify the associated resource class using the `JsonApiResource` attribute.
31+
- The specified resource class **MUST** implement `IJsonApiResource`.
32+
33+
The resource class defines how the model will be exposed to client applications.
3234

3335
For example:
3436

@@ -49,15 +51,16 @@ public class PersonResource : IJsonApiResource
4951
}
5052
```
5153

52-
We use [AutoMapper](http://automapper.org/) to map from the context model to the JsonApiResource.
53-
The below snippet shows how you can specify a custom mapping expression in your `Startup` class that will apped '_1' to the resource name.
54+
We use [AutoMapper](http://automapper.org/) to map from the model class to the resource class.
55+
The below snippet shows how you can specify a custom mapping expression in your `Startup` class that will append `_1` to the resource name.
5456
Check out [AutoMapper's Wiki](https://github.com/AutoMapper/AutoMapper/wiki) for detailed mapping options.
5557

5658
```
5759
services.AddJsonApi(config => {
5860
...
5961
config.AddResourceMapping<Person, PersonResource>(map =>
6062
{
63+
// resource.Name = model.Name + "_1"
6164
map.ForMember("Name", opt => opt.MapFrom(src => $"{((Person)src).Name}_1"));
6265
});
6366
...
@@ -76,7 +79,7 @@ services.AddJsonApi(config => {
7679
});
7780
```
7881

79-
The controller **must** implement `IJsonApiController`, and it **may** inherit from [JsonApiController](https://github.com/Research-Institute/json-api-dotnet-core/blob/master/JsonApiDotNetCore/Controllers/JsonApiController.cs).
82+
The controller **MUST** implement `IJsonApiController`, and it **MAY** inherit from [JsonApiController](https://github.com/Research-Institute/json-api-dotnet-core/blob/master/JsonApiDotNetCore/Controllers/JsonApiController.cs).
8083
Constructor dependency injection will work like normal.
8184
Any services added in your `Startup.ConfigureServices()` method will be injected into the constructor parameters.
8285

0 commit comments

Comments
 (0)