1
- # ASP.NET Core WebApi Sample
1
+ # ASP.NET Core WebApi Sample with HATEOAS, Versioning & Swagger
2
2
3
3
In this repository I want to give a plain starting point at how to build a WebAPI with ASP.NET Core.
4
4
5
- This repository contains a controller which is dealing with houses . You can GET/POST/PUT/PATCH and DELETE them.
5
+ This repository contains a controller which is dealing with FoodItems . You can GET/POST/PUT/PATCH and DELETE them.
6
6
7
7
Hope this helps.
8
8
9
9
See the examples here:
10
10
11
- ## GET all houses
11
+ ## Versions
12
12
13
- ``` http://localhost:29435/api/house ```
13
+ ``` http://localhost:29435/swagger ```
14
+
15
+ ![ ASPNETCOREWebAPIVersions] ( ./.github/versions.jpg )
16
+
17
+ ## GET all Foods
18
+
19
+ ``` http://localhost:29435/api/v1/foods ```
14
20
15
21
![ ASPNETCOREWebAPIGET] ( ./.github/get.jpg )
16
22
17
- ## GET single house
23
+ ## GET single food
18
24
19
- ``` http://localhost:29435/api/house/1 ```
25
+ ``` http://localhost:29435/api/v1/foods/2 ```
20
26
21
27
![ ASPNETCOREWebAPIGET] ( ./.github/getSingle.jpg )
22
28
23
- ## POST a house
29
+ ## POST a foodItem
24
30
25
- ``` http://localhost:29435/api/house ```
31
+ ``` http://localhost:29435/api/v1/foods ```
26
32
27
33
``` javascript
28
34
{
29
- " street" : " MyNewStreet" ,
30
- " city" : " MyHomeTown" ,
31
- " zipCode" : 1234
35
+ " name" : " Lasagne" ,
36
+ " type" : " Main" ,
37
+ " calories" : 3000 ,
38
+ " created" : " 2017-09-16T17:50:08.1510899+02:00"
32
39
}
33
40
```
34
41
35
42
![ ASPNETCOREWebAPIGET] ( ./.github/post.jpg )
36
43
37
44
## PUT a house
38
45
39
- ``` http://localhost:29435/api/house /5 ```
46
+ ``` http://localhost:29435/api/v1/foods /5 ```
40
47
41
48
``` javascript
42
49
{
43
- " id " : 5 ,
44
- " street " : " HAAALELUJAH " ,
45
- " city " : " HAAALELUJAH-TOWN " ,
46
- " zipCode " : 1234657
50
+ " name " : " Lasagne2 " ,
51
+ " type " : " Main " ,
52
+ " calories " : 3000 ,
53
+ " created " : " 2017-09-16T17:50:08.1510899+02:00 "
47
54
}
48
55
```
49
56
@@ -52,19 +59,19 @@ See the examples here:
52
59
53
60
## PATCH a house
54
61
55
- ``` http://localhost:29435/api/house/4 ```
62
+ ``` http://localhost:29435/api/v1/foods/5 ```
56
63
57
64
``` javascript
58
65
[
59
- { " op" : " replace" , " path" : " /street " , " value" : " PatchStreet " }
66
+ { " op" : " replace" , " path" : " /name " , " value" : " mynewname " }
60
67
]
61
68
```
62
69
63
70
![ ASPNETCOREWebAPIGET] ( ./.github/patch.jpg )
64
71
65
72
## DELETE a house
66
73
67
- ``` http://localhost:29435/api/house ```
74
+ ``` http://localhost:29435/api/v1/foods/5 ```
68
75
69
76
70
77
![ ASPNETCOREWebAPIGET] ( ./.github/delete.jpg )
0 commit comments