mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Added docs for the tree api (#5835)
* Added docs for the tree api * Updated swagger docs * Added missing response definition * Updated swagger docs * Fixed swagger docs
This commit is contained in:
		@@ -16,6 +16,30 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// GetTree get the tree of a repository.
 | 
					// GetTree get the tree of a repository.
 | 
				
			||||||
func GetTree(ctx *context.APIContext) {
 | 
					func GetTree(ctx *context.APIContext) {
 | 
				
			||||||
 | 
						// swagger:operation GET /repos/{owner}/{repo}/git/trees/{sha} repository GetTree
 | 
				
			||||||
 | 
						// ---
 | 
				
			||||||
 | 
						// summary: Gets the tree of a repository.
 | 
				
			||||||
 | 
						// produces:
 | 
				
			||||||
 | 
						// - application/json
 | 
				
			||||||
 | 
						// parameters:
 | 
				
			||||||
 | 
						// - name: owner
 | 
				
			||||||
 | 
						//   in: path
 | 
				
			||||||
 | 
						//   description: owner of the repo
 | 
				
			||||||
 | 
						//   type: string
 | 
				
			||||||
 | 
						//   required: true
 | 
				
			||||||
 | 
						// - name: repo
 | 
				
			||||||
 | 
						//   in: path
 | 
				
			||||||
 | 
						//   description: name of the repo
 | 
				
			||||||
 | 
						//   type: string
 | 
				
			||||||
 | 
						//   required: true
 | 
				
			||||||
 | 
						// - name: sha
 | 
				
			||||||
 | 
						//   in: path
 | 
				
			||||||
 | 
						//   description: sha of the commit
 | 
				
			||||||
 | 
						//   type: string
 | 
				
			||||||
 | 
						//   required: true
 | 
				
			||||||
 | 
						// responses:
 | 
				
			||||||
 | 
						//   "200":
 | 
				
			||||||
 | 
						//     "$ref": "#/responses/GitTreeResponse"
 | 
				
			||||||
	sha := ctx.Params("sha")
 | 
						sha := ctx.Params("sha")
 | 
				
			||||||
	if len(sha) == 0 {
 | 
						if len(sha) == 0 {
 | 
				
			||||||
		ctx.Error(400, "sha not provided", nil)
 | 
							ctx.Error(400, "sha not provided", nil)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,3 +133,10 @@ type swaggerResponseAttachment struct {
 | 
				
			|||||||
	//in: body
 | 
						//in: body
 | 
				
			||||||
	Body api.Attachment `json:"body"`
 | 
						Body api.Attachment `json:"body"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GitTreeResponse
 | 
				
			||||||
 | 
					// swagger:response GitTreeResponse
 | 
				
			||||||
 | 
					type swaggerGitTreeResponse struct {
 | 
				
			||||||
 | 
						//in: body
 | 
				
			||||||
 | 
						Body api.GitTreeResponse `json:"body"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1663,6 +1663,46 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "/repos/{owner}/{repo}/git/trees/{sha}": {
 | 
				
			||||||
 | 
					      "get": {
 | 
				
			||||||
 | 
					        "produces": [
 | 
				
			||||||
 | 
					          "application/json"
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        "tags": [
 | 
				
			||||||
 | 
					          "repository"
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        "summary": "Gets the tree of a repository.",
 | 
				
			||||||
 | 
					        "operationId": "GetTree",
 | 
				
			||||||
 | 
					        "parameters": [
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            "type": "string",
 | 
				
			||||||
 | 
					            "description": "owner of the repo",
 | 
				
			||||||
 | 
					            "name": "owner",
 | 
				
			||||||
 | 
					            "in": "path",
 | 
				
			||||||
 | 
					            "required": true
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            "type": "string",
 | 
				
			||||||
 | 
					            "description": "name of the repo",
 | 
				
			||||||
 | 
					            "name": "repo",
 | 
				
			||||||
 | 
					            "in": "path",
 | 
				
			||||||
 | 
					            "required": true
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            "type": "string",
 | 
				
			||||||
 | 
					            "description": "sha of the commit",
 | 
				
			||||||
 | 
					            "name": "sha",
 | 
				
			||||||
 | 
					            "in": "path",
 | 
				
			||||||
 | 
					            "required": true
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        "responses": {
 | 
				
			||||||
 | 
					          "200": {
 | 
				
			||||||
 | 
					            "$ref": "#/responses/GitTreeResponse"
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    "/repos/{owner}/{repo}/hooks": {
 | 
					    "/repos/{owner}/{repo}/hooks": {
 | 
				
			||||||
      "get": {
 | 
					      "get": {
 | 
				
			||||||
        "produces": [
 | 
					        "produces": [
 | 
				
			||||||
@@ -7040,6 +7080,38 @@
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
					      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "GitEntry": {
 | 
				
			||||||
 | 
					      "description": "GitEntry represents a git tree",
 | 
				
			||||||
 | 
					      "type": "object",
 | 
				
			||||||
 | 
					      "properties": {
 | 
				
			||||||
 | 
					        "mode": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "Mode"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "path": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "Path"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "sha": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "SHA"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "size": {
 | 
				
			||||||
 | 
					          "type": "integer",
 | 
				
			||||||
 | 
					          "format": "int64",
 | 
				
			||||||
 | 
					          "x-go-name": "Size"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "type": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "Type"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "url": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "URL"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    "GitObject": {
 | 
					    "GitObject": {
 | 
				
			||||||
      "type": "object",
 | 
					      "type": "object",
 | 
				
			||||||
      "title": "GitObject represents a Git object.",
 | 
					      "title": "GitObject represents a Git object.",
 | 
				
			||||||
@@ -7059,6 +7131,32 @@
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
					      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "GitTreeResponse": {
 | 
				
			||||||
 | 
					      "description": "GitTreeResponse returns a git tree",
 | 
				
			||||||
 | 
					      "type": "object",
 | 
				
			||||||
 | 
					      "properties": {
 | 
				
			||||||
 | 
					        "sha": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "SHA"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "tree": {
 | 
				
			||||||
 | 
					          "type": "array",
 | 
				
			||||||
 | 
					          "items": {
 | 
				
			||||||
 | 
					            "$ref": "#/definitions/GitEntry"
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          "x-go-name": "Entries"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "truncated": {
 | 
				
			||||||
 | 
					          "type": "boolean",
 | 
				
			||||||
 | 
					          "x-go-name": "Truncated"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "url": {
 | 
				
			||||||
 | 
					          "type": "string",
 | 
				
			||||||
 | 
					          "x-go-name": "URL"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    "Issue": {
 | 
					    "Issue": {
 | 
				
			||||||
      "description": "Issue represents an issue in a repository",
 | 
					      "description": "Issue represents an issue in a repository",
 | 
				
			||||||
      "type": "object",
 | 
					      "type": "object",
 | 
				
			||||||
@@ -8200,6 +8298,12 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "GitTreeResponse": {
 | 
				
			||||||
 | 
					      "description": "GitTreeResponse",
 | 
				
			||||||
 | 
					      "schema": {
 | 
				
			||||||
 | 
					        "$ref": "#/definitions/GitTreeResponse"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    "Hook": {
 | 
					    "Hook": {
 | 
				
			||||||
      "description": "Hook",
 | 
					      "description": "Hook",
 | 
				
			||||||
      "schema": {
 | 
					      "schema": {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user