From 289f3ffe3e45cd5d88edf0ae8adf4ddd84847bba Mon Sep 17 00:00:00 2001 From: imjoey Date: Thu, 28 Nov 2019 09:28:55 +0800 Subject: [PATCH] Fix failing to protect branch Signed-off-by: imjoey --- api/swagger.yaml | 25 ++++++++++++++++------ docs/BranchProtectionPutParam.md | 10 +++++++++ docs/RepositoriesApi.md | 14 ++---------- gitee/api_repositories.go | 15 ++++--------- gitee/model_branch_protection_put_param.go | 16 ++++++++++++++ 5 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 docs/BranchProtectionPutParam.md create mode 100644 gitee/model_branch_protection_put_param.go diff --git a/api/swagger.yaml b/api/swagger.yaml index 2f0279d..2d4bf43 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -182,13 +182,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)" @@ -207,6 +200,13 @@ paths: required: true type: "string" x-exportParamName: "Branch" + - in: "body" + name: "body" + description: "设置分支保护参数" + required: true + schema: + $ref: "#/definitions/BranchProtectionPutParam" + x-exportParamName: "Body" responses: 200: description: "返回格式" @@ -16046,3 +16046,14 @@ definitions: example: access_token: "access_token" body: "body" + BranchProtectionPutParam: + type: "object" + properties: + access_token: + type: "string" + description: "用户授权码" + x-exportParamName: "AccessToken" + x-optionalDataType: "String" + description: "branch protection parameter" + example: + access_token: "access_token" \ No newline at end of file diff --git a/docs/BranchProtectionPutParam.md b/docs/BranchProtectionPutParam.md new file mode 100644 index 0000000..1da5dc8 --- /dev/null +++ b/docs/BranchProtectionPutParam.md @@ -0,0 +1,10 @@ +# BranchProtectionPutParam + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AccessToken** | **string** | 用户授权码 | [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 495253c..4bc20e2 100644 --- a/docs/RepositoriesApi.md +++ b/docs/RepositoriesApi.md @@ -2153,7 +2153,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) # **PutV5ReposOwnerRepoBranchesBranchProtection** -> CompleteBranch PutV5ReposOwnerRepoBranchesBranchProtection(ctx, owner, repo, branch, optional) +> CompleteBranch PutV5ReposOwnerRepoBranchesBranchProtection(ctx, owner, repo, branch, body) 设置分支保护 设置分支保护 @@ -2166,17 +2166,7 @@ Name | Type | Description | Notes **owner** | **string**| 仓库所属空间地址(企业、组织或个人的地址path) | **repo** | **string**| 仓库路径(path) | **branch** | **string**| 分支名称 | - **optional** | ***PutV5ReposOwnerRepoBranchesBranchProtectionOpts** | optional parameters | nil if no parameters - -### Optional Parameters -Optional parameters are passed through a pointer to a PutV5ReposOwnerRepoBranchesBranchProtectionOpts struct - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - - - - **accessToken** | **optional.String**| 用户授权码 | + **body** | [**BranchProtectionPutParam**](BranchProtectionPutParam.md)| 设置分支保护参数 | ### Return type diff --git a/gitee/api_repositories.go b/gitee/api_repositories.go index 2668156..272cefe 100644 --- a/gitee/api_repositories.go +++ b/gitee/api_repositories.go @@ -5349,17 +5349,11 @@ RepositoriesApiService 设置分支保护 * @param owner 仓库所属空间地址(企业、组织或个人的地址path) * @param repo 仓库路径(path) * @param branch 分支名称 - * @param optional nil or *PutV5ReposOwnerRepoBranchesBranchProtectionOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 + * @param body 设置分支保护参数 @return CompleteBranch */ - -type PutV5ReposOwnerRepoBranchesBranchProtectionOpts struct { - AccessToken optional.String -} - -func (a *RepositoriesApiService) PutV5ReposOwnerRepoBranchesBranchProtection(ctx context.Context, owner string, repo string, branch string, localVarOptionals *PutV5ReposOwnerRepoBranchesBranchProtectionOpts) (CompleteBranch, *http.Response, error) { +func (a *RepositoriesApiService) PutV5ReposOwnerRepoBranchesBranchProtection(ctx context.Context, owner string, repo string, branch string, body BranchProtectionPutParam) (CompleteBranch, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} @@ -5395,9 +5389,8 @@ func (a *RepositoriesApiService) PutV5ReposOwnerRepoBranchesBranchProtection(ctx if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarOptionals != nil && localVarOptionals.AccessToken.IsSet() { - localVarFormParams.Add("access_token", parameterToString(localVarOptionals.AccessToken.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_branch_protection_put_param.go b/gitee/model_branch_protection_put_param.go new file mode 100644 index 0000000..909c885 --- /dev/null +++ b/gitee/model_branch_protection_put_param.go @@ -0,0 +1,16 @@ +/* + * 码云 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 + +// branch protection parameter +type BranchProtectionPutParam struct { + // 用户授权码 + AccessToken string `json:"access_token,omitempty"` +} -- GitLab