Skip to content

Commit 72ff651

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix/#237
2 parents 4087b1f + e8cbc4b commit 72ff651

File tree

57 files changed

+677
-1371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+677
-1371
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
before_script:
77
- psql -c 'create database JsonApiDotNetCoreExample;' -U postgres
88
mono: none
9-
dotnet: 2.0.3 # https://www.microsoft.com/net/download/linux
9+
dotnet: 2.1.105 # https://www.microsoft.com/net/download/linux
1010
branches:
1111
only:
1212
- master

CONTRIBUTING.MD

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
## Workflow
44

5-
1. Search through the issues to see if your particular issue has already been discovered and possibly addressed
6-
2. Open an issue if you can't find anything helpful
7-
3. Open a PR for proposed changes
5+
1. Search through the issues to see if your particular issue has already been discovered and possibly addressed
6+
2. Open an issue if you can't find anything helpful
7+
3. Open a PR for proposed changes
88

99
## Commit Guidelines
1010

1111
I have chosen to loosely follow the [Angular Commit Guidelines](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit)
12+
13+
# Documentation
14+
15+
If you'd like to help us improve our documentation, please checkout our [GitHub pages repository](https://github.com/json-api-dotnet/json-api-dotnet.github.io) where we host our documentation.

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,23 @@
1212

1313
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.
1414

15+
## Getting Started
16+
17+
These are some steps you can take to help you understand what this project is and how you can use it:
18+
19+
- [What is json:api and why should I use it?](https://nordicapis.com/the-benefits-of-using-json-api/)
20+
- [The json:api specification](http://jsonapi.org/format/)
21+
- [Demo [Video]](https://youtu.be/KAMuo6K7VcE)
22+
- [Our documentation](https://json-api-dotnet.github.io)
23+
- Check out the examples in the next section
24+
1525
## Examples
1626

1727
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.
1828

1929
## Installation And Usage
2030

21-
See [the documentation](https://json-api-dotnet.github.io/JsonApiDotNetCore/) for detailed usage.
31+
See [the documentation](https://json-api-dotnet.github.io/#/) for detailed usage.
2232

2333
### Models
2434

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```ini
2+
BenchmarkDotNet=v0.10.10, OS=Mac OS X 10.12
3+
Processor=Intel Core i5-5257U CPU 2.70GHz (Broadwell), ProcessorCount=4
4+
.NET Core SDK=2.1.4
5+
[Host] : .NET Core 2.0.5 (Framework 4.6.0.0), 64bit RyuJIT
6+
DefaultJob : .NET Core 2.0.5 (Framework 4.6.0.0), 64bit RyuJIT
7+
```
8+
9+
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
10+
| ---------- | --------: | ---------: | ---------: | -----: | --------: |
11+
| UsingSplit | 421.08 ns | 19.3905 ns | 54.0529 ns | 0.4725 | 744 B |
12+
| Current | 52.23 ns | 0.8052 ns | 0.7532 ns | - | 0 B |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
``` ini
2+
3+
BenchmarkDotNet=v0.10.10, OS=Mac OS X 10.12
4+
Processor=Intel Core i5-5257U CPU 2.70GHz (Broadwell), ProcessorCount=4
5+
.NET Core SDK=2.1.4
6+
[Host] : .NET Core 2.0.5 (Framework 4.6.0.0), 64bit RyuJIT
7+
Job-XFMVNE : .NET Core 2.0.5 (Framework 4.6.0.0), 64bit RyuJIT
8+
9+
LaunchCount=3 TargetCount=20 WarmupCount=10
10+
11+
```
12+
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
13+
|--------------------------- |-----------:|----------:|----------:|-------:|----------:|
14+
| UsingSplit | 1,197.6 ns | 11.929 ns | 25.933 ns | 0.9251 | 1456 B |
15+
| UsingSpanWithStringBuilder | 1,542.0 ns | 15.249 ns | 33.792 ns | 0.9460 | 1488 B |
16+
| UsingSpanWithNoAlloc | 272.6 ns | 2.265 ns | 5.018 ns | 0.0863 | 136 B |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
``` ini
2+
3+
BenchmarkDotNet=v0.10.10, OS=Mac OS X 10.12
4+
Processor=Intel Core i5-5257U CPU 2.70GHz (Broadwell), ProcessorCount=4
5+
.NET Core SDK=2.1.4
6+
[Host] : .NET Core 2.0.5 (Framework 4.6.0.0), 64bit RyuJIT
7+
DefaultJob : .NET Core 2.0.5 (Framework 4.6.0.0), 64bit RyuJIT
8+
9+
10+
```
11+
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
12+
|----------- |----------:|----------:|----------:|-------:|----------:|
13+
| UsingSplit | 157.28 ns | 2.9689 ns | 5.8602 ns | 0.2134 | 336 B |
14+
| Current | 39.96 ns | 0.6489 ns | 0.6070 ns | - | 0 B |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Attributes.Exporters;
3+
4+
namespace Benchmarks.JsonApiContext
5+
{
6+
[MarkdownExporter, MemoryDiagnoser]
7+
public class PathIsRelationship_Benchmarks
8+
{
9+
private const string PATH = "https://example.com/api/v1/namespace/articles/relationships/author/";
10+
11+
[Benchmark]
12+
public void Current()
13+
=> JsonApiDotNetCore.Services.JsonApiContext.PathIsRelationship(PATH);
14+
15+
[Benchmark]
16+
public void UsingSplit() => UsingSplitImpl(PATH);
17+
18+
private bool UsingSplitImpl(string path)
19+
{
20+
var split = path.Split('/');
21+
return split[split.Length - 2] == "relationships";
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Attributes.Exporters;
3+
using BenchmarkDotNet.Attributes.Jobs;
4+
5+
namespace Benchmarks.LinkBuilder
6+
{
7+
[MarkdownExporter, SimpleJob(launchCount : 3, warmupCount : 10, targetCount : 20), MemoryDiagnoser]
8+
public class LinkBuilder_GetNamespaceFromPath_Benchmarks
9+
{
10+
private const string PATH = "/api/some-really-long-namespace-path/resources/current/articles";
11+
private const string ENTITY_NAME = "articles";
12+
13+
[Benchmark]
14+
public void UsingSplit() => GetNamespaceFromPath_BySplitting(PATH, ENTITY_NAME);
15+
16+
[Benchmark]
17+
public void Current() => GetNameSpaceFromPath_Current(PATH, ENTITY_NAME);
18+
19+
public static string GetNamespaceFromPath_BySplitting(string path, string entityName)
20+
{
21+
var nSpace = string.Empty;
22+
var segments = path.Split('/');
23+
24+
for (var i = 1; i < segments.Length; i++)
25+
{
26+
if (segments[i].ToLower() == entityName)
27+
break;
28+
29+
nSpace += $"/{segments[i]}";
30+
}
31+
32+
return nSpace;
33+
}
34+
35+
public static string GetNameSpaceFromPath_Current(string path, string entityName)
36+
=> JsonApiDotNetCore.Builders.LinkBuilder.GetNamespaceFromPath(path, entityName);
37+
}
38+
}

benchmarks/Program.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using BenchmarkDotNet.Running;
2+
using Benchmarks.JsonApiContext;
3+
using Benchmarks.LinkBuilder;
24
using Benchmarks.Query;
5+
using Benchmarks.RequestMiddleware;
36
using Benchmarks.Serialization;
47

58
namespace Benchmarks {
@@ -8,7 +11,10 @@ static void Main(string[] args) {
811
var switcher = new BenchmarkSwitcher(new[] {
912
typeof(JsonApiDeserializer_Benchmarks),
1013
typeof(JsonApiSerializer_Benchmarks),
11-
typeof(QueryParser_Benchmarks)
14+
typeof(QueryParser_Benchmarks),
15+
typeof(LinkBuilder_GetNamespaceFromPath_Benchmarks),
16+
typeof(ContainsMediaTypeParameters_Benchmarks),
17+
typeof(PathIsRelationship_Benchmarks)
1218
});
1319
switcher.Run(args);
1420
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Attributes.Exporters;
3+
using JsonApiDotNetCore.Internal;
4+
5+
namespace Benchmarks.RequestMiddleware
6+
{
7+
[MarkdownExporter, MemoryDiagnoser]
8+
public class ContainsMediaTypeParameters_Benchmarks
9+
{
10+
private const string MEDIA_TYPE = "application/vnd.api+json; version=1";
11+
12+
[Benchmark]
13+
public void UsingSplit() => UsingSplitImpl(MEDIA_TYPE);
14+
15+
[Benchmark]
16+
public void Current()
17+
=> JsonApiDotNetCore.Middleware.RequestMiddleware.ContainsMediaTypeParameters(MEDIA_TYPE);
18+
19+
private bool UsingSplitImpl(string mediaType)
20+
{
21+
var mediaTypeArr = mediaType.Split(';');
22+
return (mediaTypeArr[0] == Constants.ContentType && mediaTypeArr.Length == 2);
23+
}
24+
}
25+
}

couscous.yml

-116
This file was deleted.

docs/ContextGraph.md

-58
This file was deleted.

0 commit comments

Comments
 (0)