Skip to content

v2.1.0 #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jul 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
86311d9
feat(*): interface segregation
jaredcnance Jun 12, 2017
f8a7ac2
Merge branch 'feat/cqrs' into unstable
jaredcnance Jun 12, 2017
54575d7
Merge branch 'unstable' into master
jaredcnance Jun 14, 2017
40ffa82
Merge pull request #133 from Research-Institute/master
jaredcnance Jun 14, 2017
60f7713
Merge pull request #134 from Research-Institute/master
jaredcnance Jun 14, 2017
46f2d07
feat(serialization): improve support for complex attrs
jaredcnance Jun 13, 2017
3de6d21
fix(typeHelper): handle complex types
jaredcnance Jun 23, 2017
deb57df
feat(services): complete interface segregation
jaredcnance Jun 25, 2017
fc7f702
chore(examples): move projects under examples directory
jaredcnance Jun 25, 2017
504dfa1
feat(reports): add reports example
jaredcnance Jun 25, 2017
18ae7c8
Merge branch 'feat/#125' into unstable
jaredcnance Jun 25, 2017
d804628
chore(#117): remove deprecated constructor
jaredcnance Jun 25, 2017
59fc512
feat(#129): optionally disable links
jaredcnance Jun 25, 2017
c131839
feat(#130): disable query params
jaredcnance Jun 27, 2017
c08fbe0
feat(#128): immutable attributes
jaredcnance Jun 28, 2017
ee0025f
feat(#139): handle empty strings in type helper
jaredcnance Jun 28, 2017
a894f69
feat(#138): improved exception handling
jaredcnance Jun 28, 2017
6ed2a4f
test(base-controller): add unit tests
jaredcnance Jul 2, 2017
e792b8e
Merge pull request #140 from Research-Institute/unstable
jaredcnance Jul 2, 2017
b46d299
add documentation
jaredcnance Jul 2, 2017
93b063e
add documentation
jaredcnance Jul 2, 2017
6e92a9f
fix(#126): implicitly add db context to context graph
jaredcnance Jul 2, 2017
ad8787e
fix(ctx-graph-builder): set link flags to prevent ordering issues
jaredcnance Jul 2, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.user
.couscous/
docs/Template-Dark/
.idea/
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"isShellCommand": true,
"args": [],
"options": {
"cwd": "${workspaceRoot}/src/JsonApiDotNetCoreExample"
"cwd": "${workspaceRoot}/src/Examples/JsonApiDotNetCoreExample"
},
"tasks": [
{
Expand Down
22 changes: 20 additions & 2 deletions JsonApiDotnetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore", "src\JsonApiDotNetCore\JsonApiDotNetCore.csproj", "{C0EC9E70-EB2E-436F-9D94-FA16FA774123}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreExample", "src\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj", "{97EE048B-16C0-43F6-BDA9-4E762B2F579F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreExample", "src\Examples\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj", "{97EE048B-16C0-43F6-BDA9-4E762B2F579F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}"
EndProject
Expand All @@ -18,12 +18,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkExample", "src\NoEntityFrameworkExample\NoEntityFrameworkExample.csproj", "{570165EC-62B5-4684-A139-8D2A30DD4475}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkExample", "src\Examples\NoEntityFrameworkExample\NoEntityFrameworkExample.csproj", "{570165EC-62B5-4684-A139-8D2A30DD4475}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkTests", "test\NoEntityFrameworkTests\NoEntityFrameworkTests.csproj", "{73DA578D-A63F-4956-83ED-6D7102E09140}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{6D4BD85A-A262-44C6-8572-FE3A30410BF3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{026FBC6C-AF76-4568-9B87-EC73457899FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportsExample", "src\Examples\ReportsExample\ReportsExample.csproj", "{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -94,6 +98,18 @@ Global
{6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x64.Build.0 = Release|x64
{6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x86.ActiveCfg = Release|x86
{6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x86.Build.0 = Release|x86
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x64.ActiveCfg = Debug|x64
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x64.Build.0 = Debug|x64
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x86.ActiveCfg = Debug|x86
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x86.Build.0 = Debug|x86
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|Any CPU.Build.0 = Release|Any CPU
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x64.ActiveCfg = Release|x64
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x64.Build.0 = Release|x64
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x86.ActiveCfg = Release|x86
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -105,5 +121,7 @@ Global
{570165EC-62B5-4684-A139-8D2A30DD4475} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
{73DA578D-A63F-4956-83ED-6D7102E09140} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{6D4BD85A-A262-44C6-8572-FE3A30410BF3} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{026FBC6C-AF76-4568-9B87-EC73457899FD} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions docs/Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ public class Person : Identifiable<int>
}
```

### Immutability

Attributes can be marked as immutable which will prevent `PATCH` requests
from updating them:

```csharp
public class Person : Identifiable<int>
{
[Attr("first-name", immutable: true)]
public string FirstName { get; set; }
}
```

## Relationships

In order for navigation properties to be identified in the model,
Expand Down
48 changes: 48 additions & 0 deletions docs/ResourceServices.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,52 @@ public class MyModelService : IResourceService<MyModel>
return await _dal.GetModelAsync();
}
}
```

### Limited Requirements

In some cases it may be necessary to only expose a few methods on the resource.
For this reason, we have created a hierarchy of service interfaces that can be used to get the
exact implementation you require. Below is a table outlining these interfaces:

![interfaces](service_table.png)


In order to take advantage of these interfaces you first need to inject the service for each implemented interface.
Using Autofac, as an example, this is simply:

```csharp
public class MyResourceService : ICreateService<MyResource>, IDeleteService<MyResource> {
// ...
}
```

```csharp
public class Startup {
public IServiceProvider ConfigureServices(IServiceCollection services) {
builder.RegisterType<MyResourceService>().AsImplementedInterfaces();
}
}
```

Then in the controller, you should inherit the base controller and pass the services into
the named, optional base parameters:

```csharp
public class MyResourcesController : BaseJsonApiController<MyResource> {

public MyResourcesController(
IJsonApiContext jsonApiContext,
ICreateService<MyResource> create,
IDeleteService<MyResource> delete
) : base(jsonApiContext, create: create, delete: delete) { }

[HttpPost]
public override async Task<IActionResult> PostAsync([FromBody] MyResource entity)
=> await base.PostAsync(entity);

[HttpDelete("{id}")]
public override async Task<IActionResult>DeleteAsync(int id)
=> await base.DeleteAsync(id);
}
```
Binary file added docs/service_table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CustomJsonApiController(
IResourceService<T, TId> resourceService,
ILoggerFactory loggerFactory)
{
_jsonApiContext = jsonApiContext.ApplyContext<T>();
_jsonApiContext = jsonApiContext.ApplyContext<T>(this);
_resourceService = resourceService;
_logger = loggerFactory.CreateLogger<JsonApiDotNetCore.Controllers.JsonApiController<T, TId>>();
}
Expand All @@ -63,7 +63,7 @@ public CustomJsonApiController(
IJsonApiContext jsonApiContext,
IResourceService<T, TId> resourceService)
{
_jsonApiContext = jsonApiContext.ApplyContext<T>();
_jsonApiContext = jsonApiContext.ApplyContext<T>(this);
_resourceService = resourceService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
<ProjectReference Include="../../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
<ProjectReference Include="../JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj" />
<ProjectReference Include="../../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
<ProjectReference Include="../../Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/Examples/ReportsExample/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "wwwroot/lib"
}
Loading