mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-05 01:45:22 +02: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:
parent
bb5f694fc5
commit
3edb0c5894
42 changed files with 2361 additions and 66 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue