Skip to content

Commit 51e47b8

Browse files
committed
update docs -1
1 parent 491a6cb commit 51e47b8

26 files changed

+423
-56
lines changed

docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_site/

docs/GET_Articles_Response

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":[]}

docs/api/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
###############
2+
# temp file #
3+
###############
4+
*.yml

src/JsonApiDotNetCore/api/.manifest renamed to docs/api/.manifest

+143-46
Large diffs are not rendered by default.
File renamed without changes.

src/JsonApiDotNetCore/docfx.json renamed to docs/docfx.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{
44
"src": [
55
{
6-
"files": [ "**.csproj" ],
7-
"src": "C:\\Users\\jnance\\dev\\json-api-dotnet-core\\src\\JsonApiDotNetCore"
6+
"files": [ "**/JsonApiDotNetCore.csproj" ],
7+
"src": "../"
88
}
99
],
1010
"dest": "api",
@@ -21,8 +21,9 @@
2121
},
2222
{
2323
"files": [
24-
"articles/**.md",
25-
"articles/**/toc.yml",
24+
"getting-started/**.md",
25+
"getting-started/**/toc.yml",
26+
"request-examples/**.md",
2627
"toc.yml",
2728
"*.md"
2829
]

docs/generate.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# generates ./request-examples documents
3+
4+
function cleanup() {
5+
kill -9 $(lsof -ti tcp:5001) &2>/dev/null
6+
}
7+
8+
cleanup
9+
dotnet run -p ../src/Examples/GettingStarted/GettingStarted.csproj &
10+
app_pid=$!
11+
12+
13+
{ # try
14+
echo "Started app with PID $app_pid"
15+
16+
sleep 5
17+
18+
echo "sleep over"
19+
20+
for path in ./request-examples/*.sh; do
21+
op_name=$(basename "$path" .sh | sed 's/.*-//')
22+
echo $op_name
23+
bash $path | jq . > "./request-examples/$op_name-Response.json"
24+
done
25+
}
26+
27+
# docfx metadata
28+
29+
cleanup

docs/generators/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Installing
2+
3+
...
4+
5+
## Creating a project template
6+
7+
```
8+
dotnet new jadnc
9+
```

docs/getting-started/intro.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Introduction
2+
3+
What is this
4+
5+
[!code-csharp[Main](../../src/Examples/OperationsExample/Program.cs)]
File renamed without changes.

docs/index.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# JSON API .Net Core
2+
3+
A [{ json:api }](https://jsonapi.org) web application framework for .Net Core.
4+
5+
## Objectives
6+
7+
### 1. Eliminate Boilerplate
8+
9+
The goal of this package is to facility the development of json:api applications that leverage the full range
10+
of features provided by the specification.
11+
12+
Eliminate CRUD boilerplate and provide the following features across all your resource endpoints:
13+
14+
- Relationship inclusion and navigation
15+
- Filtering
16+
- Sorting
17+
- Pagination
18+
- Sparse field selection
19+
- And more...
20+
21+
As an example, with just the following model and controller definitions, you can service all of the following requests:
22+
23+
```http
24+
GET /articles HTTP/1.1
25+
Accept: application/vnd.api+json
26+
```
27+
28+
[!code-csharp[Article](../src/Examples/GettingStarted/Models/Article.cs)]
29+
30+
[!code-csharp[ArticlesController](../src/Examples/GettingStarted/Controllers/ArticlesController.cs)]
31+
32+
### 2. Extensibility
33+
34+
This library relies heavily on an open-generic-based dependency injection model which allows for easy per-resource customization.
35+
36+

docs/request-examples/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
curl http://localhost:5001/api/articles \
2+
-H "Accept: application/vnd.api+json" \
3+
-H "Content-Type: application/vnd.api+json" \
4+
-d '{
5+
"data": {
6+
"type": "articles",
7+
"attributes": {
8+
"title": "test"
9+
}
10+
}
11+
}'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
curl http://localhost:5001/api/articles \
2+
-H "Accept: application/vnd.api+json"
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
curl http://localhost:5001/api/articles/1 \
2+
-H "Accept: application/vnd.api+json"

docs/request-examples/index.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Examples
2+
3+
These requests have been generated against the "GettingStarted" application and are updated on every deployment.
4+
5+
## Create Article
6+
7+
[!code-sh[CREATE](000-CREATE_Article.sh)]
8+
[!code-json[CREATE](CREATE_Article-Response.json)]
9+
10+
11+
## Get All Articles
12+
13+
[!code-sh[GET Request](001-GET_Articles.sh)]
14+
[!code-json[GET Response](GET_Articles-Response.json)]
15+
16+
## Get Article By Id
17+
18+
[!code-sh[GET Request](002-GET_Article.sh)]
19+
[!code-json[GET Response](GET_Article-Response.json)]

docs/toc.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- name: Getting Started
2+
href: getting-started/
3+
4+
- name: API
5+
href: api/
6+
homepage: api/index.md
7+
8+
- name: Request Examples
9+
href: request-examples/
10+
homepage: request-examples/index.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using JsonApiDotNetCore.Controllers;
2+
using JsonApiDotNetCore.Services;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace GettingStarted
6+
{
7+
public class ArticlesController : JsonApiController<Article>
8+
{
9+
public ArticlesController(
10+
IJsonApiContext jsonApiContext,
11+
IResourceService<Article> resourceService,
12+
ILoggerFactory loggerFactory)
13+
: base(jsonApiContext, resourceService, loggerFactory)
14+
{ }
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.EntityFrameworkCore;
2+
3+
namespace GettingStarted
4+
{
5+
public class SampleDbContext : DbContext
6+
{
7+
public SampleDbContext(DbContextOptions<SampleDbContext> options)
8+
: base(options)
9+
{ }
10+
11+
public DbSet<Article> Articles { get; set; }
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Folder Include="wwwroot\" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="../../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.0" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
19+
</ItemGroup>
20+
21+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using JsonApiDotNetCore.Models;
2+
3+
namespace GettingStarted
4+
{
5+
public class Article : Identifiable
6+
{
7+
[Attr("title")]
8+
public string Title { get; set; }
9+
}
10+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace GettingStarted
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
BuildWebHost(args).Run();
18+
}
19+
20+
public static IWebHost BuildWebHost(string[] args) =>
21+
WebHost.CreateDefaultBuilder(args)
22+
.UseStartup<Startup>()
23+
.UseUrls("http://localhost:5001")
24+
.Build();
25+
}
26+
}

src/Examples/GettingStarted/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Sample project
2+
3+
## Usage
4+
5+
`dotnet run` to run the project
6+
7+
You can verify the project is running by checking this endpoint:
8+
`localhost:5001/api/sample-model`
9+
10+
For further documentation and implementation of a JsonApiDotnetCore Application see the documentation or GitHub page:
11+
12+
Repository: https://github.com/json-api-dotnet/JsonApiDotNetCore
13+
14+
Documentation: https://json-api-dotnet.github.io/
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.EntityFrameworkCore;
10+
using JsonApiDotNetCore.Extensions;
11+
12+
namespace GettingStarted
13+
{
14+
public class Startup
15+
{
16+
// This method gets called by the runtime. Use this method to add services to the container.
17+
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
18+
public void ConfigureServices(IServiceCollection services)
19+
{
20+
services.AddDbContext<SampleDbContext>(options =>
21+
{
22+
options.UseSqlite("Data Source=sample.db");
23+
});
24+
25+
services.AddJsonApi<SampleDbContext>(options =>
26+
{
27+
options.Namespace = "api";
28+
});
29+
}
30+
31+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
32+
public void Configure(IApplicationBuilder app, IHostingEnvironment env, SampleDbContext context)
33+
{
34+
if (env.IsDevelopment())
35+
{
36+
app.UseDeveloperExceptionPage();
37+
}
38+
39+
context.Database.EnsureDeleted(); // indicies need to be reset
40+
context.Database.EnsureCreated();
41+
42+
app.UseJsonApi();
43+
}
44+
}
45+
}

src/JsonApiDotNetCore/articles/intro.md

-1
This file was deleted.

src/JsonApiDotNetCore/toc.yml

-5
This file was deleted.

0 commit comments

Comments
 (0)