Skip to content

Commit

Permalink
Add repo fork swagger (go-gitea#1941)
Browse files Browse the repository at this point in the history
  • Loading branch information
cez81 authored and lunny committed Jun 12, 2017
1 parent 91f27bf commit ad70af1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions public/swagger.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,42 @@
}
}
},
"/repos/{owner}/{repo}/forks": {
"get": {
"produces": [
"application/json"
],
"operationId": "listForks",
"responses": {
"200": {
"$ref": "#/responses/RepositoryList"
},
"500": {
"$ref": "#/responses/error"
}
}
},
"post": {
"produces": [
"application/json"
],
"operationId": "createFork",
"responses": {
"202": {
"$ref": "#/responses/Repository"
},
"403": {
"$ref": "#/responses/forbidden"
},
"422": {
"$ref": "#/responses/validationError"
},
"500": {
"$ref": "#/responses/error"
}
}
}
},
"/repos/{username}/{reponame}/mirror-sync": {
"post": {
"produces": [
Expand Down
20 changes: 20 additions & 0 deletions routers/api/v1/repo/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import (

// ListForks list a repository's forks
func ListForks(ctx *context.APIContext) {
// swagger:route GET /repos/{owner}/{repo}/forks listForks
//
// Produces:
// - application/json
//
// Responses:
// 200: RepositoryList
// 500: error

forks, err := ctx.Repo.Repository.GetForks()
if err != nil {
ctx.Error(500, "GetForks", err)
Expand All @@ -32,6 +41,17 @@ func ListForks(ctx *context.APIContext) {

// CreateFork create a fork of a repo
func CreateFork(ctx *context.APIContext, form api.CreateForkOption) {
// swagger:route POST /repos/{owner}/{repo}/forks createFork
//
// Produces:
// - application/json
//
// Responses:
// 202: Repository
// 403: forbidden
// 422: validationError
// 500: error

repo := ctx.Repo.Repository
var forker *models.User // user/org that will own the fork
if form.Organization == nil {
Expand Down

0 comments on commit ad70af1

Please sign in to comment.