Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit ff6d394

Browse files
author
Kevin Richter
committed
Add API docs
1 parent 391c1fb commit ff6d394

File tree

7 files changed

+164
-68
lines changed

7 files changed

+164
-68
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

config/esdoc-wrapper.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

package.json

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,53 @@
33
"version": "1.0.0",
44
"scripts": {
55
"copy-pages": "cp pages/* source/",
6-
"compile-docs-wrapper": "npx esdoc -c config/esdoc-wrapper.json"
6+
"compile-docs-wrapper": "npx esdoc"
77
},
88
"dependencies": {
99
"@mapcreator/maps4news": "^1.4.22",
1010
"esdoc": "^1.1.0",
1111
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
1212
"esdoc-standard-plugin": "^1.0.0",
1313
"swagger-ui": "^3.18.1"
14+
},
15+
"esdoc": {
16+
"name": "maps4news",
17+
"index": "./node_modules/@mapcreator/maps4news/README.md",
18+
"source": "./node_modules/@mapcreator/maps4news/src",
19+
"destination": "./source/wrapper",
20+
"plugins": [
21+
{
22+
"name": "esdoc-standard-plugin",
23+
"option": {
24+
"accessor": {
25+
"access": [
26+
"public",
27+
"protected"
28+
],
29+
"autoPrivate": true
30+
},
31+
"undocumentIdentifier": {
32+
"enable": true
33+
},
34+
"unexportedIdentifier": {
35+
"enable": false
36+
},
37+
"typeInference": {
38+
"enable": true
39+
},
40+
"brand": {
41+
"title": "Maps4News Api Wrapper",
42+
"description": "Maps4News Api Javascript Wrapper"
43+
}
44+
}
45+
},
46+
{
47+
"name": "esdoc-ecmascript-proposal-plugin",
48+
"option": {
49+
"all": true
50+
}
51+
}
52+
]
1453
}
54+
1555
}

pages/api.html.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Introduction
2+
3+
...
4+
5+
6+
# Return Data
7+
8+
> For Success Responses
9+
10+
```json
11+
{
12+
"success": true,
13+
"data": {}
14+
}
15+
```
16+
17+
> For Error Responses
18+
19+
```json
20+
{
21+
"success": false,
22+
"error": {
23+
"type": "HttpNotFoundException",
24+
"message": "Page Not Found"
25+
}
26+
}
27+
```
28+
29+
All JSON responses from the API a wrapper in a base object.
30+
31+
Be sure to include an `Accept: application/json` header, otherwise errors like `401, 403 & 404` will either return HTML or redirect you to the login page.
32+
33+
34+
# Query Parameters
35+
36+
The API has a few query parameters available that you can use to help find the resources you need.
37+
38+
All three of these query parameters are only available on listing endpoints, so endpoints that return an array of items.
39+
40+
## Pagination
41+
42+
> As Query Parameter
43+
44+
```
45+
?page=1&per_page=50
46+
```
47+
48+
> As Header
49+
50+
```
51+
X-Page: 1
52+
X-Per-Page: 50
53+
```
54+
55+
By default de API returns 12 items per page. This can be increased to a maximum of 50 items per page.
56+
57+
## Sorting
58+
59+
> Sort ID Descending and Name Ascending
60+
61+
```
62+
?sort=-id,name
63+
```
64+
65+
The API supports sorting ascending or descending sorting on multiple columns (seperated by a comma) on the resources.
66+
67+
**Sortable columns are whitelisted inside the API, there is currently no documentation on what columns are whitelisted**
68+
69+
## Searching
70+
71+
> Search for name LIKE "Kevin" and company That Ends With "4News"
72+
73+
```
74+
?search[name]=Kevin&search[company]=$:4News
75+
```
76+
77+
Searching can be done on multiple columns, we use the URL array syntax for this.
78+
The basic syntax is `operator:value`, so: `=:Maps4News`
79+
80+
**The same is for searchable columns, these are whitelisted per resource**
81+
82+
The available operators are:
83+
84+
- `!`: Not operator
85+
- `=`: Equals operator
86+
- `>`: Bigger than operator
87+
- `<`: Smaller than operator
88+
- `>=`: Bigger than or equals operator
89+
- `<=`: Smaller than or equals operator
90+
- `^`: Starts with operator
91+
- `$`: Ends with operator
92+
- Or no operator, that will result in a `LIKE` statement
93+
94+
# Keywords
95+
96+
There are a few keywords throughout the API that you can use in the url as shortcuts to certain resources.
97+
98+
```
99+
GET /users/me
100+
```
101+
102+
For example, you can use `me` as an keyword for a user. This will return the resource of the logged in user.
103+
104+
<br/>
105+
106+
```
107+
GET /organisations/mine
108+
```
109+
110+
A manager can use the `mine` keyword to get a list of organisations he/she manages.
111+
112+
<br/>
113+
114+
```
115+
GET /jobs/1/revisions/last
116+
```
117+
118+
To get the last revision for a job, you can use the `last` keyword.

pages/index.html.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ search: true
1919

2020
Welcome to the API documentation for Maps4News.
2121

22-
This API allows you to manage everything about your account and your organisation. As well as generate Maps.
22+
Our API allows you to manage everything about your Maps4News account and your organisation. As well as generate Maps.
2323

2424
# API Wrapper
2525

@@ -121,10 +121,10 @@ You must have a valid client registered with us to be able to use the API. Clien
121121

122122
# Next
123123

124-
The next step in learning about our API would be to look into our extensive documentation about all the available endpoints.
124+
The next step in learning about our API would be to look into our OpenAPI documentation about all the available endpoints.
125125

126-
[API Swagger docs](api.html)
126+
[API OpenAPI (Swagger) Definition](/api/index.html)
127127

128128
Our you can look into how the wrapper works.
129129

130-
[API Wrapper docs](wrapper.html)
130+
[API Wrapper Class Documentation](/wrapper/index.html)

source/includes/_directory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
- [API](/api.html)
55
- [API OpenAPI (Swagger) Definition](/api/index.html)
66
- [API Wrapper](/wrapper.html)
7-
- [API Wrapper API (Class) Documentation](/wrapper/index.html)
7+
- [API Wrapper Class Documentation](/wrapper/index.html)

0 commit comments

Comments
 (0)