gitea源码

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package admin
  4. import (
  5. api "code.gitea.io/gitea/modules/structs"
  6. "code.gitea.io/gitea/modules/web"
  7. "code.gitea.io/gitea/routers/api/v1/repo"
  8. "code.gitea.io/gitea/services/context"
  9. )
  10. // CreateRepo api for creating a repository
  11. func CreateRepo(ctx *context.APIContext) {
  12. // swagger:operation POST /admin/users/{username}/repos admin adminCreateRepo
  13. // ---
  14. // summary: Create a repository on behalf of a user
  15. // consumes:
  16. // - application/json
  17. // produces:
  18. // - application/json
  19. // parameters:
  20. // - name: username
  21. // in: path
  22. // description: username of the user who will own the created repository
  23. // type: string
  24. // required: true
  25. // - name: repository
  26. // in: body
  27. // required: true
  28. // schema: { "$ref": "#/definitions/CreateRepoOption" }
  29. // responses:
  30. // "201":
  31. // "$ref": "#/responses/Repository"
  32. // "400":
  33. // "$ref": "#/responses/error"
  34. // "403":
  35. // "$ref": "#/responses/forbidden"
  36. // "404":
  37. // "$ref": "#/responses/notFound"
  38. // "409":
  39. // "$ref": "#/responses/error"
  40. // "422":
  41. // "$ref": "#/responses/validationError"
  42. form := web.GetForm(ctx).(*api.CreateRepoOption)
  43. repo.CreateUserRepo(ctx, ctx.ContextUser, *form)
  44. }