Skip to content

Commit 8e46750

Browse files
author
Bart Koelman
committed
Added documentation
1 parent 0e29b4f commit 8e46750

File tree

13 files changed

+237
-15
lines changed

13 files changed

+237
-15
lines changed

docs/internals/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Internals
22

3-
The section contains overviews for the inner workings of the JsonApiDotNetCore library.
3+
This section contains overviews for the inner workings of the JsonApiDotNetCore library.

docs/request-examples/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ _Note that cURL requires "[" and "]" in URLs to be escaped._
4545

4646
# Writing data
4747

48-
### Create
48+
### Create resource
4949

5050
[!code-ps[REQUEST](010_CREATE_Person.ps1)]
5151
[!code-json[RESPONSE](010_CREATE_Person_Response.json)]
5252

53-
### Create with relationship
53+
### Create resource with relationship
5454

5555
[!code-ps[REQUEST](011_CREATE_Book-with-Author.ps1)]
5656
[!code-json[RESPONSE](011_CREATE_Book-with-Author_Response.json)]
5757

58-
### Update
58+
### Update resource
5959

6060
[!code-ps[REQUEST](012_PATCH_Book.ps1)]
6161
[!code-json[RESPONSE](012_PATCH_Book_Response.json)]
6262

63-
### Delete
63+
### Delete resource
6464

6565
[!code-ps[REQUEST](013_DELETE_Book.ps1)]
6666
[!code-json[RESPONSE](013_DELETE_Book_Response.json)]
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/usage/resources/relationships.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public class TodoItem : Identifiable<int>
2020
}
2121
```
2222

23-
The convention used to locate the foreign key property (e.g. `OwnerId`) can be changed on
24-
the @JsonApiDotNetCore.Configuration.JsonApiOptions#JsonApiDotNetCore_Configuration_JsonApiOptions_RelatedIdMapper
25-
2623
## HasMany
2724

2825
```c#

docs/usage/toc.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
## [Relationships](resources/relationships.md)
44
## [Resource Definitions](resources/resource-definitions.md)
55

6+
# Reading data
7+
## [Filtering](reading/filtering.md)
8+
## [Sorting](reading/sorting.md)
9+
## [Pagination](reading/pagination.md)
10+
## [Sparse Fieldset Selection](reading/sparse-fieldset-selection.md)
11+
## [Including Relationships](reading/including-relationships.md)
12+
13+
# Writing data
14+
## [Creating](writing/creating.md)
15+
## [Updating](writing/updating.md)
16+
## [Deleting](writing/deleting.md)
17+
618
# [Resource Graph](resource-graph.md)
719
# [Options](options.md)
8-
# [Filtering](filtering.md)
9-
# [Sorting](sorting.md)
10-
# [Pagination](pagination.md)
11-
# [Sparse Fieldset Selection](sparse-fieldset-selection.md)
12-
# [Including Relationships](including-relationships.md)
1320
# [Routing](routing.md)
1421
# [Errors](errors.md)
1522
# [Metadata](meta.md)

docs/usage/writing/creating.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Creating resources
2+
3+
A single resource can be created by sending a POST request. The next example creates a new article:
4+
5+
```http
6+
POST /articles HTTP/1.1
7+
8+
{
9+
"data": {
10+
"type": "articles",
11+
"attributes": {
12+
"caption": "A new article!",
13+
"url": "www.website.com"
14+
}
15+
}
16+
}
17+
```
18+
19+
When using client-generated IDs and only attributes from the request have changed, the server returns `204 No Content`.
20+
Otherwise, the server returns `200 OK`, along with the updated resource and its newly assigned ID.
21+
22+
In both cases, a `Location` header is returned that contains the URL to the new resource.
23+
24+
# Creating resources with relationships
25+
26+
It is possible to create a new resource and establish relationships to existing resources in a single request.
27+
The example below creates an article and sets both its owner and tags.
28+
29+
```http
30+
POST /articles HTTP/1.1
31+
32+
{
33+
"data": {
34+
"type": "articles",
35+
"attributes": {
36+
"caption": "A new article!"
37+
},
38+
"relationships": {
39+
"author": {
40+
"data": {
41+
"type": "person",
42+
"id": "101"
43+
}
44+
},
45+
"tags": {
46+
"data": [
47+
{
48+
"type": "tag",
49+
"id": "123"
50+
},
51+
{
52+
"type": "tag",
53+
"id": "456"
54+
}
55+
]
56+
}
57+
}
58+
}
59+
}
60+
```
61+
62+
# Response body
63+
64+
POST requests can be combined with query string parameters that are normally used for reading data, such as `include` and `fields`. For example:
65+
66+
```http
67+
POST /articles?include=owner&fields[owner]=firstName HTTP/1.1
68+
69+
{
70+
...
71+
}
72+
```
73+
74+
After the resource has been created on the server, it is re-fetched from the database using the specified query string parameters and returned to the client.

0 commit comments

Comments
 (0)