From 0212e16159769bee035c75c7f404743ce4733720 Mon Sep 17 00:00:00 2001 From: georgecao Date: Tue, 21 Apr 2020 17:30:20 +0800 Subject: [PATCH 1/2] modify json format file for pr commit file list --- gitee/model_pull_request_files.go | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/gitee/model_pull_request_files.go b/gitee/model_pull_request_files.go index 538698f..1f1dd6f 100644 --- a/gitee/model_pull_request_files.go +++ b/gitee/model_pull_request_files.go @@ -9,14 +9,26 @@ package gitee +type PRFilePath struct { + Diff string `json:"diff,omitempty"` + Newpath string `json:"new_path,omitempty"` + Oldpath string `json:"old_path,omitempty"` + Amode string `json:"a_mode,omitempty"` + Bmode string `json:"b_mode,omitempty"` + Newfile bool `json:"new_file,omitempty"` + Renamefile bool `json:"renamed_file,omitempty"` + Deletefile bool `json:"deleted_file,omitempty"` + Toolarge bool `json:"too_large,omitempty"` +} + // Pull Request Commit文件列表。最多显示300条diff type PullRequestFiles struct { - Sha string `json:"sha,omitempty"` - Filename string `json:"filename,omitempty"` - Status string `json:"status,omitempty"` - Additions string `json:"additions,omitempty"` - Deletions string `json:"deletions,omitempty"` - BlobUrl string `json:"blob_url,omitempty"` - RawUrl string `json:"raw_url,omitempty"` - Patch string `json:"patch,omitempty"` + Sha string `json:"sha,omitempty"` + Filename string `json:"filename,omitempty"` + Status string `json:"status,omitempty"` + Additions string `json:"additions,omitempty"` + Deletions string `json:"deletions,omitempty"` + BlobUrl string `json:"blob_url,omitempty"` + RawUrl string `json:"raw_url,omitempty"` + Patch PRFilePath `json:"patch,omitempty"` } -- Gitee From da0719cf78f5ee0ae72cd29659ac59a27da5d978 Mon Sep 17 00:00:00 2001 From: georgecao Date: Thu, 23 Apr 2020 16:46:14 +0800 Subject: [PATCH 2/2] modify swagger.yaml for two api: PostV5ReposOwnerRepoContentsPath & GetV5ReposOwnerRepoPulls --- README.md | 2 + api/swagger.yaml | 145 ++++++++++++++++---------- docs/NewFileParam.md | 17 +++ docs/PullRequestFilePath.md | 18 ++++ docs/RepositoriesApi.md | 23 +--- gitee/api_repositories.go | 44 +------- gitee/model_new_file_param.go | 29 ++++++ gitee/model_pull_request_file_path.go | 23 ++++ gitee/model_pull_request_files.go | 2 +- 9 files changed, 187 insertions(+), 116 deletions(-) create mode 100644 docs/NewFileParam.md create mode 100644 docs/PullRequestFilePath.md create mode 100644 gitee/model_new_file_param.go create mode 100644 gitee/model_pull_request_file_path.go diff --git a/README.md b/README.md index 6d07bea..b8f004f 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,7 @@ Class | Method | HTTP request | Description - [Milestone](docs/Milestone.md) - [Namespace](docs/Namespace.md) - [NamespaceMini](docs/NamespaceMini.md) + - [NewFileParam](docs/NewFileParam.md) - [Note](docs/Note.md) - [OperateLog](docs/OperateLog.md) - [ProgramBasic](docs/ProgramBasic.md) @@ -294,6 +295,7 @@ Class | Method | HTTP request | Description - [PullRequestCommentPostParam](docs/PullRequestCommentPostParam.md) - [PullRequestComments](docs/PullRequestComments.md) - [PullRequestCommits](docs/PullRequestCommits.md) + - [PullRequestFilePath](docs/PullRequestFilePath.md) - [PullRequestFiles](docs/PullRequestFiles.md) - [PullRequestMergePutParam](docs/PullRequestMergePutParam.md) - [PullRequestUpdateParam](docs/PullRequestUpdateParam.md) diff --git a/api/swagger.yaml b/api/swagger.yaml index 6a97913..e3e7e81 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -876,13 +876,6 @@ paths: produces: - "application/json" parameters: - - name: "access_token" - in: "formData" - description: "用户授权码" - required: false - type: "string" - x-exportParamName: "AccessToken" - x-optionalDataType: "String" - name: "owner" in: "path" description: "仓库所属空间地址(企业、组织或个人的地址path)" @@ -901,53 +894,13 @@ paths: required: true type: "string" x-exportParamName: "Path" - - name: "content" - in: "formData" - description: "文件内容, 要用 base64 编码" - required: true - type: "string" - x-exportParamName: "Content" - - name: "message" - in: "formData" - description: "提交信息" + - name: "body" + in: "body" + description: "描述文件信息" required: true - type: "string" - x-exportParamName: "Message" - - name: "branch" - in: "formData" - description: "分支名称。默认为仓库对默认分支" - required: false - type: "string" - x-exportParamName: "Branch" - x-optionalDataType: "String" - - name: "committer[name]" - in: "formData" - description: "Committer的名字,默认为当前用户的名字" - required: false - type: "string" - x-exportParamName: "CommitterName" - x-optionalDataType: "String" - - name: "committer[email]" - in: "formData" - description: "Committer的邮箱,默认为当前用户的邮箱" - required: false - type: "string" - x-exportParamName: "CommitterEmail" - x-optionalDataType: "String" - - name: "author[name]" - in: "formData" - description: "Author的名字,默认为当前用户的名字" - required: false - type: "string" - x-exportParamName: "AuthorName" - x-optionalDataType: "String" - - name: "author[email]" - in: "formData" - description: "Author的邮箱,默认为当前用户的邮箱" - required: false - type: "string" - x-exportParamName: "AuthorEmail" - x-optionalDataType: "String" + schema: + $ref: "#/definitions/NewFileParam" + x-exportParamName: "Body" responses: 201: description: "返回格式" @@ -14430,6 +14383,38 @@ definitions: sha: "sha" url: "url" parents: "parents" + PullRequestFilePath: + type: "object" + properties: + diff: + type: "string" + new_path: + type: "string" + old_path: + type: "string" + a_mode: + type: "string" + b_mode: + type: "string" + new_file: + type: "boolean" + renamed_file: + type: "boolean" + deleted_file: + type: "boolean" + too_large: + type: "boolean" + description: "单个文件的patch信息" + example: + diff: "patch" + new_path: "repo/src-test.yaml" + old_path: "repo/src-test.yaml" + a_mode: "100644" + b_mode: "100644" + new_file: false + renamed_file: false + deleted_file: false + too_large: false PullRequestFiles: type: "object" properties: @@ -14448,7 +14433,7 @@ definitions: raw_url: type: "string" patch: - type: "string" + $ref: "#/definitions/PullRequestFilePath" description: "Pull Request Commit文件列表。最多显示300条diff" example: patch: "patch" @@ -16177,3 +16162,55 @@ definitions: private: "false" path: "new_repo_path" default_branch: "master" + NewFileParam: + type: "object" + properties: + access_token: + type: "string" + description: "用户授权码" + x-exportParamName: "AccessToken" + x-optionalDataType: "String" + content: + type: "string" + description: "文件内容, 要用 base64 编码" + x-exportParamName: "Content" + x-optionalDataType: "String" + message: + type: "string" + description: "提交信息" + x-exportParamName: "Message" + x-optionalDataType: "String" + branch: + type: "string" + description: "分支名称。默认为仓库对默认分支" + x-exportParamName: "Branch" + x-optionalDataType: "String" + committer[name]: + type: "string" + description: "Committer的名字,默认为当前用户的名字" + x-exportParamName: "CommitterName" + x-optionalDataType: "String" + committer[email]: + type: "string" + description: "Committer的邮箱,默认为当前用户的邮箱" + x-exportParamName: "CommitterEmail" + x-optionalDataType: "String" + author[name]: + type: "string" + description: "Author的名字,默认为当前用户的名字" + x-exportParamName: "AuthorName" + x-optionalDataType: "String" + author[email]: + type: "string" + description: "Author的邮箱,默认为当前用户的邮箱" + x-exportParamName: "AuthorEmail" + x-optionalDataType: "String" + example: + access_token: "access_token" + content: "aGVsbG9nZW9yZ2U=" + message: "add test file" + branch: "master" + committer[name]: "testcommitter" + committer[email]: "testcommiteremail" + author[name]: "testauthor" + author[email]: "testauthoremail" diff --git a/docs/NewFileParam.md b/docs/NewFileParam.md new file mode 100644 index 0000000..981d301 --- /dev/null +++ b/docs/NewFileParam.md @@ -0,0 +1,17 @@ +# NewFileParam + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AccessToken** | **string** | 用户授权码 | [optional] [default to null] +**Content** | **string** | 文件内容, 要用 base64 编码 | [optional] [default to null] +**Message** | **string** | 提交信息 | [optional] [default to null] +**Branch** | **string** | 分支名称。默认为仓库对默认分支 | [optional] [default to null] +**CommitterName** | **string** | Committer的名字,默认为当前用户的名字 | [optional] [default to null] +**CommitterEmail** | **string** | Committer的邮箱,默认为当前用户的邮箱 | [optional] [default to null] +**AuthorName** | **string** | Author的名字,默认为当前用户的名字 | [optional] [default to null] +**AuthorEmail** | **string** | Author的邮箱,默认为当前用户的邮箱 | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/PullRequestFilePath.md b/docs/PullRequestFilePath.md new file mode 100644 index 0000000..22b1c3c --- /dev/null +++ b/docs/PullRequestFilePath.md @@ -0,0 +1,18 @@ +# PullRequestFilePath + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Diff** | **string** | | [optional] [default to null] +**NewPath** | **string** | | [optional] [default to null] +**OldPath** | **string** | | [optional] [default to null] +**AMode** | **string** | | [optional] [default to null] +**BMode** | **string** | | [optional] [default to null] +**NewFile** | **bool** | | [optional] [default to null] +**RenamedFile** | **bool** | | [optional] [default to null] +**DeletedFile** | **bool** | | [optional] [default to null] +**TooLarge** | **bool** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/RepositoriesApi.md b/docs/RepositoriesApi.md index 4587cf0..9ef313a 100644 --- a/docs/RepositoriesApi.md +++ b/docs/RepositoriesApi.md @@ -1872,7 +1872,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **PostV5ReposOwnerRepoContentsPath** -> CommitContent PostV5ReposOwnerRepoContentsPath(ctx, owner, repo, path, content, message, optional) +> CommitContent PostV5ReposOwnerRepoContentsPath(ctx, owner, repo, path, body) 新建文件 新建文件 @@ -1885,26 +1885,7 @@ Name | Type | Description | Notes **owner** | **string**| 仓库所属空间地址(企业、组织或个人的地址path) | **repo** | **string**| 仓库路径(path) | **path** | **string**| 文件的路径 | - **content** | **string**| 文件内容, 要用 base64 编码 | - **message** | **string**| 提交信息 | - **optional** | ***PostV5ReposOwnerRepoContentsPathOpts** | optional parameters | nil if no parameters - -### Optional Parameters -Optional parameters are passed through a pointer to a PostV5ReposOwnerRepoContentsPathOpts struct - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - - - - - - **accessToken** | **optional.String**| 用户授权码 | - **branch** | **optional.String**| 分支名称。默认为仓库对默认分支 | - **committerName** | **optional.String**| Committer的名字,默认为当前用户的名字 | - **committerEmail** | **optional.String**| Committer的邮箱,默认为当前用户的邮箱 | - **authorName** | **optional.String**| Author的名字,默认为当前用户的名字 | - **authorEmail** | **optional.String**| Author的邮箱,默认为当前用户的邮箱 | + **body** | [**NewFileParam**](NewFileParam.md)| 描述文件信息 | ### Return type diff --git a/gitee/api_repositories.go b/gitee/api_repositories.go index 6df47f6..18ab71e 100644 --- a/gitee/api_repositories.go +++ b/gitee/api_repositories.go @@ -4638,29 +4638,11 @@ RepositoriesApiService 新建文件 * @param owner 仓库所属空间地址(企业、组织或个人的地址path) * @param repo 仓库路径(path) * @param path 文件的路径 - * @param content 文件内容, 要用 base64 编码 - * @param message 提交信息 - * @param optional nil or *PostV5ReposOwnerRepoContentsPathOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 - * @param "Branch" (optional.String) - 分支名称。默认为仓库对默认分支 - * @param "CommitterName" (optional.String) - Committer的名字,默认为当前用户的名字 - * @param "CommitterEmail" (optional.String) - Committer的邮箱,默认为当前用户的邮箱 - * @param "AuthorName" (optional.String) - Author的名字,默认为当前用户的名字 - * @param "AuthorEmail" (optional.String) - Author的邮箱,默认为当前用户的邮箱 + * @param body 描述文件信息 @return CommitContent */ - -type PostV5ReposOwnerRepoContentsPathOpts struct { - AccessToken optional.String - Branch optional.String - CommitterName optional.String - CommitterEmail optional.String - AuthorName optional.String - AuthorEmail optional.String -} - -func (a *RepositoriesApiService) PostV5ReposOwnerRepoContentsPath(ctx context.Context, owner string, repo string, path string, content string, message string, localVarOptionals *PostV5ReposOwnerRepoContentsPathOpts) (CommitContent, *http.Response, error) { +func (a *RepositoriesApiService) PostV5ReposOwnerRepoContentsPath(ctx context.Context, owner string, repo string, path string, body NewFileParam) (CommitContent, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -4696,26 +4678,8 @@ func (a *RepositoriesApiService) PostV5ReposOwnerRepoContentsPath(ctx context.Co if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarOptionals != nil && localVarOptionals.AccessToken.IsSet() { - localVarFormParams.Add("access_token", parameterToString(localVarOptionals.AccessToken.Value(), "")) - } - localVarFormParams.Add("content", parameterToString(content, "")) - localVarFormParams.Add("message", parameterToString(message, "")) - if localVarOptionals != nil && localVarOptionals.Branch.IsSet() { - localVarFormParams.Add("branch", parameterToString(localVarOptionals.Branch.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.CommitterName.IsSet() { - localVarFormParams.Add("committer[name]", parameterToString(localVarOptionals.CommitterName.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.CommitterEmail.IsSet() { - localVarFormParams.Add("committer[email]", parameterToString(localVarOptionals.CommitterEmail.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.AuthorName.IsSet() { - localVarFormParams.Add("author[name]", parameterToString(localVarOptionals.AuthorName.Value(), "")) - } - if localVarOptionals != nil && localVarOptionals.AuthorEmail.IsSet() { - localVarFormParams.Add("author[email]", parameterToString(localVarOptionals.AuthorEmail.Value(), "")) - } + // body params + localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err diff --git a/gitee/model_new_file_param.go b/gitee/model_new_file_param.go new file mode 100644 index 0000000..2beb129 --- /dev/null +++ b/gitee/model_new_file_param.go @@ -0,0 +1,29 @@ +/* + * 码云 Open API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 5.3.2 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package gitee + +type NewFileParam struct { + // 用户授权码 + AccessToken string `json:"access_token,omitempty"` + // 文件内容, 要用 base64 编码 + Content string `json:"content,omitempty"` + // 提交信息 + Message string `json:"message,omitempty"` + // 分支名称。默认为仓库对默认分支 + Branch string `json:"branch,omitempty"` + // Committer的名字,默认为当前用户的名字 + CommitterName string `json:"committer[name],omitempty"` + // Committer的邮箱,默认为当前用户的邮箱 + CommitterEmail string `json:"committer[email],omitempty"` + // Author的名字,默认为当前用户的名字 + AuthorName string `json:"author[name],omitempty"` + // Author的邮箱,默认为当前用户的邮箱 + AuthorEmail string `json:"author[email],omitempty"` +} diff --git a/gitee/model_pull_request_file_path.go b/gitee/model_pull_request_file_path.go new file mode 100644 index 0000000..33b6926 --- /dev/null +++ b/gitee/model_pull_request_file_path.go @@ -0,0 +1,23 @@ +/* + * 码云 Open API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 5.3.2 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package gitee + +// 单个文件的patch信息 +type PullRequestFilePath struct { + Diff string `json:"diff,omitempty"` + NewPath string `json:"new_path,omitempty"` + OldPath string `json:"old_path,omitempty"` + AMode string `json:"a_mode,omitempty"` + BMode string `json:"b_mode,omitempty"` + NewFile bool `json:"new_file,omitempty"` + RenamedFile bool `json:"renamed_file,omitempty"` + DeletedFile bool `json:"deleted_file,omitempty"` + TooLarge bool `json:"too_large,omitempty"` +} diff --git a/gitee/model_pull_request_files.go b/gitee/model_pull_request_files.go index 1f1dd6f..b1b80f0 100644 --- a/gitee/model_pull_request_files.go +++ b/gitee/model_pull_request_files.go @@ -30,5 +30,5 @@ type PullRequestFiles struct { Deletions string `json:"deletions,omitempty"` BlobUrl string `json:"blob_url,omitempty"` RawUrl string `json:"raw_url,omitempty"` - Patch PRFilePath `json:"patch,omitempty"` + Patch *PullRequestFilePath `json:"patch,omitempty"` } -- Gitee