Skip to content

Commit 4f787bb

Browse files
committed
http methods
1 parent dad0d54 commit 4f787bb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ the same change, be it a bugfix or a feature addition.
9898

9999
The `vendor/` update needs to be justified as part of the PR description,
100100
and must be verified by the reviewers and/or merger to always reference
101-
an existsing upstream commit.
101+
an existing upstream commit.
102102

103103
You can find more information on how to get started with it on the [Modules Uncyclo](https://github.com/golang/go/wiki/Modules).
104104

@@ -182,15 +182,22 @@ To maintain understandable code and avoid circular dependencies it is important
182182
The API is documented by [swagger](http://gitea.com/api/swagger) and is based on [GitHub API v3](https://developer.github.com/v3/).
183183
Thus, Gitea´s API should use the same endpoints and fields as GitHub´s API as far as possible, unless there are good reasons to deviate. If GitHub doesn't provide...
184184

185+
Updating an existing API does not remove existing fields unless there is a really good reason to do so.
186+
The same applies to status responses, if you notice a problem, feel free to leave a comment in the code if there is a refactoring to APIv2 (which is currently not planned).
187+
185188
All expected results (errors, success, fail messages) should be documented ([example](https://github.com/go-gitea/gitea/blob/master/routers/api/v1/repo/issue.go#L319-L327)).
186189

187190
All JSON input types must be defined as struct in `models/structs/` ([example](https://github.com/go-gitea/gitea/blob/master/modules/structs/issue.go#L76-L91)) and referenced in [routers/api/v1/swagger/options.go](https://github.com/go-gitea/gitea/blob/master/routers/api/v1/swagger/options.go), they can be used then as following: ([example](https://github.com/go-gitea/gitea/blob/master/routers/api/v1/repo/issue.go#L318)).
188191

189192
All JSON responses must be defined as struct in `models/structs/` ([example](https://github.com/go-gitea/gitea/blob/master/modules/structs/issue.go#L36-L68)) and referenced in its category in `routers/api/v1/swagger/` ([example](https://github.com/go-gitea/gitea/blob/master/routers/api/v1/swagger/issue.go#L11-L16)), they can be used as following: ([example](https://github.com/go-gitea/gitea/blob/master/routers/api/v1/repo/issue.go#L277-L279))
190193

191-
* GET endpoints return status `OK (200)`,
192-
* POST endpoints return status `Created (201)` and
193-
* DELETE endpoints return status `No Content (204)`
194+
In general, http methods are chosen as follows:
195+
* **GET** endpoints return requested object and status **OK (200)**
196+
* **DELETE** endpoints return status **No Content (204)**
197+
* **POST** endpoints return status **Created (201)**, used to **create** new objects (e.g. a User)
198+
* **PUT** endpoints return status **No Content (204)**, used to **add/assign** existing Obejcts (e.g. User) to something (e.g. Org-Team)
199+
* **PATCH** endpoints return changed object and status **OK (200)**, used to **edit/change** an existing object
200+
194201

195202
An endpoint which changes/edits a object expects all fields to be optional (except ones to identify the object, which is required).
196203

0 commit comments

Comments
 (0)