Skip to content

Commit 4ba303c

Browse files
committed
merge master into fork
2 parents 52c08af + 0664c3d commit 4ba303c

35 files changed

+1046
-622
lines changed

Build.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ dotnet build .\src\JsonApiDotNetCore -c Release
2222

2323
echo "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
2424

25-
2625
If($env:APPVEYOR_REPO_TAG -eq $true) {
2726
$revision = Get-Version-Suffix-From-Tag
2827
echo "VERSION-SUFFIX: $revision"
29-
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
30-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
28+
29+
IF ([string]::IsNullOrWhitespace($revision)){
30+
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
31+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
32+
}
33+
Else {
34+
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
35+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
36+
}
3137
}
3238
Else {
3339
echo "VERSION-SUFFIX: alpha1-$revision"

README.md

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,72 @@
1+
<p align="center">
2+
<img src ="https://raw.githubusercontent.com/json-api-dotnet/JsonApiDotnetCore/master/logo.png" />
3+
</p>
4+
15
# JSON API .Net Core
26

37
[![Build status](https://ci.appveyor.com/api/projects/status/9fvgeoxdikwkom10?svg=true)](https://ci.appveyor.com/project/jaredcnance/json-api-dotnet-core)
4-
[![Travis](https://img.shields.io/travis/Research-Institute/json-api-dotnet-core.svg?maxAge=3600&label=travis)](https://travis-ci.org/Research-Institute/json-api-dotnet-core)
8+
[![Travis](https://travis-ci.org/json-api-dotnet/JsonApiDotNetCore.svg?branch=master)](https://travis-ci.org/json-api-dotnet/JsonApiDotNetCore)
59
[![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.svg)](https://www.nuget.org/packages/JsonApiDotNetCore/)
610
[![MyGet CI](https://img.shields.io/myget/research-institute/vpre/JsonApiDotNetCore.svg)](https://www.myget.org/feed/research-institute/package/nuget/JsonApiDotNetCore)
711
[![Join the chat at https://gitter.im/json-api-dotnet-core/Lobby](https://badges.gitter.im/json-api-dotnet-core/Lobby.svg)](https://gitter.im/json-api-dotnet-core/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
812
[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
913

1014
A framework for building [json:api](http://jsonapi.org/) compliant web APIs. The ultimate goal of this library is to eliminate as much boilerplate as possible by offering out-of-the-box features such as sorting, filtering and pagination. You just need to focus on defining the resources and implementing your custom business logic. This library has been designed around dependency injection making extensibility incredibly easy.
1115

16+
## Examples
17+
18+
See the [examples](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/master/src/Examples) directory for up-to-date sample applications. There is also a [Todo List App](https://github.com/json-api-dotnet/TodoListExample) that includes a JADNC API and an EmberJs client.
19+
1220
## Installation And Usage
1321

14-
See the documentation [here](https://research-institute.github.io/json-api-dotnet-core)
22+
See [the documentation](https://json-api-dotnet.github.io/JsonApiDotNetCore/) for detailed usage.
23+
24+
### Models
25+
26+
```csharp
27+
public class Article : Identifiable
28+
{
29+
[Attr("name")]
30+
public string Name { get; set; }
31+
}
32+
```
33+
34+
### Controllers
35+
36+
```csharp
37+
public class ArticlesController : JsonApiController<Article>
38+
{
39+
public ArticlesController(
40+
IJsonApiContext jsonApiContext,
41+
IResourceService<Article> resourceService)
42+
: base(jsonApiContext, resourceService) { }
43+
}
44+
```
45+
46+
### Middleware
47+
48+
```csharp
49+
public class Startup
50+
{
51+
public IServiceProvider ConfigureServices(IServiceCollection services) {
52+
services.AddJsonApi<AppDbContext>();
53+
// ...
54+
}
1555

56+
public void Configure(IApplicationBuilder app) {
57+
app.UseJsonApi()
58+
// ...
59+
}
60+
}
61+
```
1662

17-
## .Net Core v2 Notes
63+
## Development Priorities
1864

19-
Branch `feat/core-2` is where I am working on .Net Core 2 compatibility tests and package upgrades.
20-
There are several blockers to be aware of:
65+
The current priorities for future development (in order):
66+
1. Operations Support ([#150](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/150))
67+
2. ASP.Net Core 2.0 Support ([#161](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/161))
68+
3. Minor features ([#105](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/105), [#144](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/144), [#162](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/162))
69+
4. Resource to Entity Mapping ([#112](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/112))
2170

22-
- Microsoft.AspNetCore.* packages target the runtime (netcoreapp) instead of netstandard. [This will be changed in future versions.](https://blogs.msdn.microsoft.com/webdev/2017/05/10/aspnet-2-preview-1/).
23-
- Can't run acceptance testing against postgres on preview runtime [pgsql.EntityFrameworkCore.PostgreSQL#171](https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/171#issuecomment-301287257)
71+
If you're interested in working on any of the above features, take a look at the [Contributing Guide](https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/CONTRIBUTING.MD)
72+
or hop on the project Gitter for more direct communication.

couscous.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ branch: gh-pages
3434

3535
# Base URL of the published website (no "/" at the end!)
3636
# You are advised to set and use this variable to write your links in the HTML layouts
37-
baseUrl: https://research-institute.github.io/json-api-dotnet-core
37+
baseUrl: https://json-api-dotnet.github.io/JsonApiDotNetCore/
3838
github:
3939
user: research-institute
4040
repo: json-api-dotnet-core
@@ -78,6 +78,9 @@ menu:
7878
filtering:
7979
text: Filtering
8080
relativeUrl: filtering.html
81+
includingrelationships:
82+
text: Including Relationships
83+
relativeUrl: includingrelationships.html
8184
pagination:
8285
text: Pagination
8386
relativeUrl: pagination.html
@@ -107,4 +110,7 @@ menu:
107110
relativeUrl: entityrepositories.html
108111
middleware:
109112
text: Middleware
110-
relativeUrl: middleware.html
113+
relativeUrl: middleware.html
114+
customqueryformat:
115+
text: Custom Query Formats
116+
relativeUrl: customqueryformat.html

docs/CustomQueryFormat.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
currentMenu: customqueryformat
3+
---
4+
5+
# Custom Query Formats
6+
7+
For information on the default query parameter formats, see the documentation for each query method.
8+
9+
In order to customize the query formats, you need to implement the `IQueryParser` interface and inject it like so:
10+
11+
```csharp
12+
services.AddScoped<IQueryParser, FooQueryParser>();
13+
```

docs/IncludingRelationships.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
currentMenu: includingrelationships
3+
---
4+
5+
# Including Relationships
6+
7+
JADNC supports [request include params](http://jsonapi-resources.com/v0.9/guide/resources.html#Included-relationships-side-loading-resources) out of the box, for side loading related resources.
8+
9+
Here’s an example from the spec:
10+
11+
```http
12+
GET /articles/1?include=comments HTTP/1.1
13+
Accept: application/vnd.api+json
14+
```
15+
16+
Will get you the following payload:
17+
18+
```json
19+
{
20+
"data": {
21+
"type": "articles",
22+
"id": "1",
23+
"attributes": {
24+
"title": "JSON API paints my bikeshed!"
25+
},
26+
"relationships": {
27+
"comments": {
28+
"links": {
29+
"self": "http://example.com/articles/1/relationships/comments",
30+
"related": "http://example.com/articles/1/comments"
31+
},
32+
"data": [
33+
{ "type": "comments", "id": "5" },
34+
{ "type": "comments", "id": "12" }
35+
]
36+
}
37+
}
38+
},
39+
"included": [{
40+
"type": "comments",
41+
"id": "5",
42+
"attributes": {
43+
"body": "First!"
44+
}
45+
}, {
46+
"type": "comments",
47+
"id": "12",
48+
"attributes": {
49+
"body": "I like XML better"
50+
}
51+
}]
52+
}
53+
```
54+

docs/Options.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,67 @@ public IServiceProvider ConfigureServices(IServiceCollection services) {
4545
// ...
4646
}
4747
```
48+
49+
## Relative Links
50+
51+
All links are absolute by default. However, you can configure relative links:
52+
53+
```csharp
54+
public IServiceProvider ConfigureServices(IServiceCollection services) {
55+
services.AddJsonApi<AppDbContext>(
56+
opt => opt.RelativeLinks = true);
57+
// ...
58+
}
59+
```
60+
61+
62+
```http
63+
GET /api/v1/articles/4309 HTTP/1.1
64+
Accept: application/vnd.api+json
65+
```
66+
67+
```json
68+
{
69+
"type": "articles",
70+
"id": "4309",
71+
"attributes": {
72+
"name": "Voluptas iure est molestias."
73+
},
74+
"relationships": {
75+
"author": {
76+
"links": {
77+
"self": "/api/v1/articles/4309/relationships/author",
78+
"related": "/api/v1/articles/4309/author"
79+
}
80+
}
81+
}
82+
}
83+
```
84+
85+
## Custom Query Parameters
86+
87+
If you would like to use custom query params (parameters not reserved by the json:api specification), you can set `AllowCustomQueryParameters = true`. The default behavior is to return an `HTTP 400 Bad Request` for unknown query parameters.
88+
89+
```csharp
90+
public IServiceProvider ConfigureServices(IServiceCollection services) {
91+
services.AddJsonApi<AppDbContext>(
92+
opt => opt.AllowCustomQueryParameters = true);
93+
// ...
94+
}
95+
```
96+
97+
## Custom Serializer Settings
98+
99+
We use Json.Net for all serialization needs. If you want to change the default serializer settings, you can:
100+
101+
```csharp
102+
public IServiceProvider ConfigureServices(IServiceCollection services) {
103+
services.AddJsonApi<AppDbContext>(
104+
opt => opt.SerializerSettings = new JsonSerializerSettings()
105+
{
106+
NullValueHandling = NullValueHandling.Ignore,
107+
ContractResolver = new DasherizedResolver()
108+
});
109+
// ...
110+
}
111+
```

0 commit comments

Comments
 (0)