1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Generate swagger json (#1402)

- Generate swagger.json into public/
- Add swagger-ui auto-installation
- Add footer link to local swagger-ui
- Add /swagger url for using app url.
- Fix Swagger-UI version via git tag
This commit is contained in:
Antoine GIRARD
2017-05-02 15:35:59 +02:00
committed by Kim "BKC" Carlbäcker
parent bb5f694fc5
commit 3edb0c5894
42 changed files with 2361 additions and 66 deletions

View File

@@ -17,6 +17,15 @@ import (
// Search search users
func Search(ctx *context.APIContext) {
// swagger:route GET /users/search userSearch
//
// Produces:
// - application/json
//
// Responses:
// 200: UserList
// 500: error
opts := &models.SearchUserOptions{
Keyword: strings.Trim(ctx.Query("q"), " "),
Type: models.UserTypeIndividual,
@@ -56,6 +65,16 @@ func Search(ctx *context.APIContext) {
// GetInfo get user's information
func GetInfo(ctx *context.APIContext) {
// swagger:route GET /users/{username} userGet
//
// Produces:
// - application/json
//
// Responses:
// 200: User
// 404: notFound
// 500: error
u, err := models.GetUserByName(ctx.Params(":username"))
if err != nil {
if models.IsErrUserNotExist(err) {
@@ -75,5 +94,13 @@ func GetInfo(ctx *context.APIContext) {
// GetAuthenticatedUser get curent user's information
func GetAuthenticatedUser(ctx *context.APIContext) {
// swagger:route GET /user userGetCurrent
//
// Produces:
// - application/json
//
// Responses:
// 200: User
ctx.JSON(200, ctx.User.APIFormat())
}