From 76a70013891d936c6981e686edd947bf59d9768f Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Thu, 23 May 2019 23:16:32 -0400 Subject: [PATCH 01/11] Fixes #7023 - API Org Visibility --- integrations/api_admin_org_test.go | 86 ++++++++++++++++++++++++++++++ integrations/api_admin_test.go | 1 + integrations/api_org_test.go | 48 ++++++++++++++++- integrations/api_user_orgs_test.go | 2 + modules/structs/org.go | 5 +- modules/structs/org_type.go | 10 ++++ routers/api/v1/admin/org.go | 8 +++ routers/api/v1/convert/convert.go | 1 + routers/api/v1/org/org.go | 15 +++++- 9 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 integrations/api_admin_org_test.go diff --git a/integrations/api_admin_org_test.go b/integrations/api_admin_org_test.go new file mode 100644 index 0000000000000..546ed861c255a --- /dev/null +++ b/integrations/api_admin_org_test.go @@ -0,0 +1,86 @@ +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package integrations + +import ( + "net/http" + "net/url" + "strings" + "testing" + + "code.gitea.io/gitea/models" + api "code.gitea.io/gitea/modules/structs" + + "github.com/stretchr/testify/assert" +) + +func TestAPIAdminOrgCreate(t *testing.T) { + onGiteaRun(t, func(*testing.T, *url.URL) { + session := loginUser(t, "user1") + token := getTokenForLoggedInUser(t, session) + + var org = api.CreateOrgOption{ + UserName: "user2_org", + FullName: "User2's organization", + Description: "This organization created by admin for user2", + Website: "https://try.gitea.io", + Location: "Shanghai", + Visibility: "private", + } + req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) + resp := session.MakeRequest(t, req, http.StatusCreated) + + var apiOrg api.Organization + DecodeJSON(t, resp, &apiOrg) + + assert.Equal(t, org.UserName, apiOrg.UserName) + assert.Equal(t, org.FullName, apiOrg.FullName) + assert.Equal(t, org.Description, apiOrg.Description) + assert.Equal(t, org.Website, apiOrg.Website) + assert.Equal(t, org.Location, apiOrg.Location) + assert.Equal(t, org.Visibility, apiOrg.Visibility) + + models.AssertExistsAndLoadBean(t, &models.User{ + Name: org.UserName, + LowerName: strings.ToLower(org.UserName), + FullName: org.FullName, + }) + }) +} + +func TestAPIAdminOrgCreateBadVisibility(t *testing.T) { + onGiteaRun(t, func(*testing.T, *url.URL) { + session := loginUser(t, "user1") + token := getTokenForLoggedInUser(t, session) + + var org = api.CreateOrgOption{ + UserName: "user2_org", + FullName: "User2's organization", + Description: "This organization created by admin for user2", + Website: "https://try.gitea.io", + Location: "Shanghai", + Visibility: "notvalid", + } + req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) + }) +} + +func TestAPIAdminOrgCreateNotAdmin(t *testing.T) { + prepareTestEnv(t) + nonAdminUsername := "user2" + session := loginUser(t, nonAdminUsername) + token := getTokenForLoggedInUser(t, session) + var org = api.CreateOrgOption{ + UserName: "user2_org", + FullName: "User2's organization", + Description: "This organization created by admin for user2", + Website: "https://try.gitea.io", + Location: "Shanghai", + Visibility: "public", + } + req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) + session.MakeRequest(t, req, http.StatusForbidden) +} diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go index 825aed9d504d0..050a7d016f1d8 100644 --- a/integrations/api_admin_test.go +++ b/integrations/api_admin_test.go @@ -144,3 +144,4 @@ func TestAPIListUsersNonAdmin(t *testing.T) { req := NewRequestf(t, "GET", "/api/v1/admin/users?token=%s", token) session.MakeRequest(t, req, http.StatusForbidden) } + diff --git a/integrations/api_org_test.go b/integrations/api_org_test.go index b36650f2e8b5f..7bd166e7482d2 100644 --- a/integrations/api_org_test.go +++ b/integrations/api_org_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestAPIOrg(t *testing.T) { +func TestAPIOrgCreate(t *testing.T) { onGiteaRun(t, func(*testing.T, *url.URL) { session := loginUser(t, "user1") @@ -28,6 +28,7 @@ func TestAPIOrg(t *testing.T) { Description: "This organization created by user1", Website: "https://try.gitea.io", Location: "Shanghai", + Visibility: "limited", } req := NewRequestWithJSON(t, "POST", "/api/v1/orgs?token="+token, &org) resp := session.MakeRequest(t, req, http.StatusCreated) @@ -40,6 +41,7 @@ func TestAPIOrg(t *testing.T) { assert.Equal(t, org.Description, apiOrg.Description) assert.Equal(t, org.Website, apiOrg.Website) assert.Equal(t, org.Location, apiOrg.Location) + assert.Equal(t, org.Visibility, apiOrg.Visibility) models.AssertExistsAndLoadBean(t, &models.User{ Name: org.UserName, @@ -72,6 +74,50 @@ func TestAPIOrg(t *testing.T) { }) } +func TestAPIOrgEdit(t *testing.T) { + onGiteaRun(t, func(*testing.T, *url.URL) { + session := loginUser(t, "user1") + + token := getTokenForLoggedInUser(t, session) + var org = api.EditOrgOption{ + FullName: "User3 organization new full name", + Description: "A new description", + Website: "https://try.gitea.io/new", + Location: "Beijing", + Visibility: "private", + } + req := NewRequestWithJSON(t, "PATCH", "/api/v1/orgs/user3?token="+token, &org) + resp := session.MakeRequest(t, req, http.StatusOK) + + var apiOrg api.Organization + DecodeJSON(t, resp, &apiOrg) + + assert.Equal(t, "user3", apiOrg.UserName) + assert.Equal(t, org.FullName, apiOrg.FullName) + assert.Equal(t, org.Description, apiOrg.Description) + assert.Equal(t, org.Website, apiOrg.Website) + assert.Equal(t, org.Location, apiOrg.Location) + assert.Equal(t, org.Visibility, apiOrg.Visibility) + }) +} + +func TestAPIOrgEditBadVisibility(t *testing.T) { + onGiteaRun(t, func(*testing.T, *url.URL) { + session := loginUser(t, "user1") + + token := getTokenForLoggedInUser(t, session) + var org = api.EditOrgOption{ + FullName: "User3 organization new full name", + Description: "A new description", + Website: "https://try.gitea.io/new", + Location: "Beijing", + Visibility: "badvisibility", + } + req := NewRequestWithJSON(t, "PATCH", "/api/v1/orgs/user3?token="+token, &org) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) + }) +} + func TestAPIOrgDeny(t *testing.T) { onGiteaRun(t, func(*testing.T, *url.URL) { setting.Service.RequireSignInView = true diff --git a/integrations/api_user_orgs_test.go b/integrations/api_user_orgs_test.go index 63e67f4356a30..6611a429d1f68 100644 --- a/integrations/api_user_orgs_test.go +++ b/integrations/api_user_orgs_test.go @@ -38,6 +38,7 @@ func TestUserOrgs(t *testing.T) { Description: "", Website: "", Location: "", + Visibility: "public", }, }, orgs) } @@ -63,6 +64,7 @@ func TestMyOrgs(t *testing.T) { Description: "", Website: "", Location: "", + Visibility: "public", }, }, orgs) } diff --git a/modules/structs/org.go b/modules/structs/org.go index fd15da1ce946c..a2e89a09ab580 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -13,7 +13,7 @@ type Organization struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` - Visibility VisibleType `json:"visibility"` + Visibility string `json:"visibility"` } // CreateOrgOption options for creating an organization @@ -24,7 +24,7 @@ type CreateOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` - Visibility VisibleType `json:"visibility"` + Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` } // EditOrgOption options for editing an organization @@ -33,4 +33,5 @@ type EditOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` + Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` } diff --git a/modules/structs/org_type.go b/modules/structs/org_type.go index 86dc5c81cd6ab..0481750cd1da4 100644 --- a/modules/structs/org_type.go +++ b/modules/structs/org_type.go @@ -40,6 +40,16 @@ func (vt VisibleType) IsPrivate() bool { return vt == VisibleTypePrivate } +// VisibilityMode provides the mode string of the visibility type (public, limited, private) +func (vt VisibleType) VisibilityMode() string { + for k, v := range VisibilityModes { + if vt == v { + return k + } + } + return "" +} + // ExtractKeysFromMapString provides a slice of keys from map func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) { for k := range in { diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index fba41a8cfece8..2b05163b2ee31 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -31,6 +31,7 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { // required: true // - name: organization // in: body + // description: `visibility` can be "public", "limited" or "private" // required: true // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: @@ -45,6 +46,11 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { return } + visibility := api.VisibleTypePublic + if form.Visibility != "" { + visibility = api.VisibilityModes[form.Visibility] + } + org := &models.User{ Name: form.UserName, FullName: form.FullName, @@ -53,7 +59,9 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { Location: form.Location, IsActive: true, Type: models.UserTypeOrganization, + Visibility: visibility, } + if err := models.CreateOrganization(org, u); err != nil { if models.IsErrUserAlreadyExist(err) || models.IsErrNameReserved(err) || diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 74fd9b3afd354..78aa9af3b690e 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -213,6 +213,7 @@ func ToOrganization(org *models.User) *api.Organization { Description: org.Description, Website: org.Website, Location: org.Location, + Visibility: org.Visibility.VisibilityMode(), } } diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index e1d0663f05aa4..0ecf802afee9c 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -75,6 +75,7 @@ func Create(ctx *context.APIContext, form api.CreateOrgOption) { // parameters: // - name: organization // in: body + // description: `visibility` can be "public", "limited" or "private" // required: true // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: @@ -90,6 +91,11 @@ func Create(ctx *context.APIContext, form api.CreateOrgOption) { return } + visibility := api.VisibleTypePublic + if form.Visibility != "" { + visibility = api.VisibilityModes[form.Visibility] + } + org := &models.User{ Name: form.UserName, FullName: form.FullName, @@ -98,6 +104,7 @@ func Create(ctx *context.APIContext, form api.CreateOrgOption) { Location: form.Location, IsActive: true, Type: models.UserTypeOrganization, + Visibility: visibility, } if err := models.CreateOrganization(org, ctx.User); err != nil { if models.IsErrUserAlreadyExist(err) || @@ -153,6 +160,7 @@ func Edit(ctx *context.APIContext, form api.EditOrgOption) { // required: true // - name: body // in: body + // description: `visibility` can be "public", "limited" or "private" // schema: // "$ref": "#/definitions/EditOrgOption" // responses: @@ -163,8 +171,11 @@ func Edit(ctx *context.APIContext, form api.EditOrgOption) { org.Description = form.Description org.Website = form.Website org.Location = form.Location - if err := models.UpdateUserCols(org, "full_name", "description", "website", "location"); err != nil { - ctx.Error(500, "UpdateUser", err) + if form.Visibility != "" { + org.Visibility = api.VisibilityModes[form.Visibility] + } + if err := models.UpdateUserCols(org, "full_name", "description", "website", "location", "visibility"); err != nil { + ctx.Error(500, "EditOrganization", err) return } From 134ee6bd6e584287b0090c2e81ef8263bd000c8a Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Thu, 23 May 2019 23:24:00 -0400 Subject: [PATCH 02/11] Fixes swagger and formatting --- integrations/api_admin_test.go | 1 - integrations/api_org_test.go | 2 +- modules/structs/org.go | 28 ++++++++++++++-------------- routers/api/v1/admin/org.go | 2 +- routers/api/v1/org/org.go | 4 ++-- templates/swagger/v1_json.tmpl | 19 +++++++++++-------- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go index 050a7d016f1d8..825aed9d504d0 100644 --- a/integrations/api_admin_test.go +++ b/integrations/api_admin_test.go @@ -144,4 +144,3 @@ func TestAPIListUsersNonAdmin(t *testing.T) { req := NewRequestf(t, "GET", "/api/v1/admin/users?token=%s", token) session.MakeRequest(t, req, http.StatusForbidden) } - diff --git a/integrations/api_org_test.go b/integrations/api_org_test.go index 7bd166e7482d2..34579aa1ea9c1 100644 --- a/integrations/api_org_test.go +++ b/integrations/api_org_test.go @@ -28,7 +28,7 @@ func TestAPIOrgCreate(t *testing.T) { Description: "This organization created by user1", Website: "https://try.gitea.io", Location: "Shanghai", - Visibility: "limited", + Visibility: "limited", } req := NewRequestWithJSON(t, "POST", "/api/v1/orgs?token="+token, &org) resp := session.MakeRequest(t, req, http.StatusCreated) diff --git a/modules/structs/org.go b/modules/structs/org.go index a2e89a09ab580..aa76b91203c5a 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -6,25 +6,25 @@ package structs // Organization represents an organization type Organization struct { - ID int64 `json:"id"` - UserName string `json:"username"` - FullName string `json:"full_name"` - AvatarURL string `json:"avatar_url"` - Description string `json:"description"` - Website string `json:"website"` - Location string `json:"location"` - Visibility string `json:"visibility"` + ID int64 `json:"id"` + UserName string `json:"username"` + FullName string `json:"full_name"` + AvatarURL string `json:"avatar_url"` + Description string `json:"description"` + Website string `json:"website"` + Location string `json:"location"` + Visibility string `json:"visibility"` } // CreateOrgOption options for creating an organization type CreateOrgOption struct { // required: true - UserName string `json:"username" binding:"Required"` - FullName string `json:"full_name"` - Description string `json:"description"` - Website string `json:"website"` - Location string `json:"location"` - Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` + UserName string `json:"username" binding:"Required"` + FullName string `json:"full_name"` + Description string `json:"description"` + Website string `json:"website"` + Location string `json:"location"` + Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` } // EditOrgOption options for editing an organization diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 2b05163b2ee31..8b10f4eb2633d 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -31,7 +31,7 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { // required: true // - name: organization // in: body - // description: `visibility` can be "public", "limited" or "private" + // description: "'visibility' can be \"public\", \"limited\" or \"private\"" // required: true // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 0ecf802afee9c..985c997d0b5f1 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -75,7 +75,7 @@ func Create(ctx *context.APIContext, form api.CreateOrgOption) { // parameters: // - name: organization // in: body - // description: `visibility` can be "public", "limited" or "private" + // description: "'visibility' can be \"public\", \"limited\" or \"private\"" // required: true // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: @@ -160,7 +160,7 @@ func Edit(ctx *context.APIContext, form api.EditOrgOption) { // required: true // - name: body // in: body - // description: `visibility` can be "public", "limited" or "private" + // description: "'visibility' can be \"public\", \"limited\" or \"private\"" // schema: // "$ref": "#/definitions/EditOrgOption" // responses: diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index c0790ac23edff..846ddec791958 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -272,6 +272,7 @@ "required": true }, { + "description": "'visibility' can be \"public\", \"limited\" or \"private\"", "name": "organization", "in": "body", "required": true, @@ -459,6 +460,7 @@ "operationId": "orgCreate", "parameters": [ { + "description": "'visibility' can be \"public\", \"limited\" or \"private\"", "name": "organization", "in": "body", "required": true, @@ -550,6 +552,7 @@ "required": true }, { + "description": "'visibility' can be \"public\", \"limited\" or \"private\"", "name": "body", "in": "body", "schema": { @@ -7140,7 +7143,8 @@ "x-go-name": "UserName" }, "visibility": { - "$ref": "#/definitions/VisibleType" + "type": "string", + "x-go-name": "Visibility" }, "website": { "type": "string", @@ -7652,6 +7656,10 @@ "type": "string", "x-go-name": "Location" }, + "visibility": { + "type": "string", + "x-go-name": "Visibility" + }, "website": { "type": "string", "x-go-name": "Website" @@ -8612,7 +8620,8 @@ "x-go-name": "UserName" }, "visibility": { - "$ref": "#/definitions/VisibleType" + "type": "string", + "x-go-name": "Visibility" }, "website": { "type": "string", @@ -9466,12 +9475,6 @@ }, "x-go-package": "code.gitea.io/gitea/models" }, - "VisibleType": { - "description": "VisibleType defines the visibility (Organization only)", - "type": "integer", - "format": "int64", - "x-go-package": "code.gitea.io/gitea/modules/structs" - }, "WatchInfo": { "description": "WatchInfo represents an API watch status of one repository", "type": "object", From 5ef5d8b5a436076b7a8d6b3548188c98580b3bd9 Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Fri, 24 May 2019 08:57:35 -0400 Subject: [PATCH 03/11] Changes per review --- modules/structs/org_type.go | 4 ++-- routers/api/v1/convert/convert.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/structs/org_type.go b/modules/structs/org_type.go index 0481750cd1da4..731a7399b673e 100644 --- a/modules/structs/org_type.go +++ b/modules/structs/org_type.go @@ -40,8 +40,8 @@ func (vt VisibleType) IsPrivate() bool { return vt == VisibleTypePrivate } -// VisibilityMode provides the mode string of the visibility type (public, limited, private) -func (vt VisibleType) VisibilityMode() string { +// VisibilityString provides the mode string of the visibility type (public, limited, private) +func (vt VisibleType) VisibilityString() string { for k, v := range VisibilityModes { if vt == v { return k diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 78aa9af3b690e..720a17905a3f6 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -213,7 +213,7 @@ func ToOrganization(org *models.User) *api.Organization { Description: org.Description, Website: org.Website, Location: org.Location, - Visibility: org.Visibility.VisibilityMode(), + Visibility: org.Visibility.VisibilityString(), } } From 145ac2bce3727211ef7057991050ef563ed96409 Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Fri, 24 May 2019 12:54:21 -0400 Subject: [PATCH 04/11] Func name change due to review --- modules/structs/org_type.go | 2 +- routers/api/v1/convert/convert.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/structs/org_type.go b/modules/structs/org_type.go index 731a7399b673e..4fb9b6fc0fdc8 100644 --- a/modules/structs/org_type.go +++ b/modules/structs/org_type.go @@ -41,7 +41,7 @@ func (vt VisibleType) IsPrivate() bool { } // VisibilityString provides the mode string of the visibility type (public, limited, private) -func (vt VisibleType) VisibilityString() string { +func (vt VisibleType) String() string { for k, v := range VisibilityModes { if vt == v { return k diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 720a17905a3f6..ba61c7e46c938 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -213,7 +213,7 @@ func ToOrganization(org *models.User) *api.Organization { Description: org.Description, Website: org.Website, Location: org.Location, - Visibility: org.Visibility.VisibilityString(), + Visibility: org.Visibility.String(), } } From bd1cd7f82b817532d2e33e1437890fd482356c7b Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 25 May 2019 17:52:52 +0100 Subject: [PATCH 05/11] Add visibility enum --- modules/structs/org.go | 6 ++++-- templates/swagger/v1_json.tmpl | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/structs/org.go b/modules/structs/org.go index aa76b91203c5a..a99197ffc33d5 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -24,7 +24,8 @@ type CreateOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` - Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` + // enum: public,limited,private + Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` } // EditOrgOption options for editing an organization @@ -33,5 +34,6 @@ type EditOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` - Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` + // enum: public,limited,private + Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` } diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 846ddec791958..e7a7e6c3ac5f8 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -7144,6 +7144,11 @@ }, "visibility": { "type": "string", + "enum": [ + "public", + "limited", + "private" + ], "x-go-name": "Visibility" }, "website": { @@ -7658,6 +7663,11 @@ }, "visibility": { "type": "string", + "enum": [ + "public", + "limited", + "private" + ], "x-go-name": "Visibility" }, "website": { From 4a5cb73c3baf0e99178468f0ad87fa59577b861c Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Sat, 25 May 2019 14:08:18 -0400 Subject: [PATCH 06/11] Fix to binding --- modules/structs/org.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/structs/org.go b/modules/structs/org.go index a99197ffc33d5..4b70cae78cae3 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -25,7 +25,7 @@ type CreateOrgOption struct { Website string `json:"website"` Location string `json:"location"` // enum: public,limited,private - Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` + Visibility string `json:"visibility" binding:"In(,public,limited,private)"` } // EditOrgOption options for editing an organization @@ -35,5 +35,5 @@ type EditOrgOption struct { Website string `json:"website"` Location string `json:"location"` // enum: public,limited,private - Visibility string `json:"visibility" binding:"In(,visible,limited,private)"` + Visibility string `json:"visibility" binding:"In(,public,limited,private)"` } From bcc1d6aeb8245ba69322a85e0c76379ed4585f35 Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Tue, 28 May 2019 10:19:25 -0400 Subject: [PATCH 07/11] Moves documentation from swagger header to schema struct for Org create/edit and Repo file create/edit/delete --- modules/structs/org.go | 2 ++ modules/structs/repo_file.go | 18 +++++++++++++--- routers/api/v1/admin/org.go | 1 - routers/api/v1/org/org.go | 3 +-- routers/api/v1/repo/file.go | 6 +++--- templates/swagger/v1_json.tmpl | 38 ++++++++++++++++++++++++++-------- 6 files changed, 50 insertions(+), 18 deletions(-) diff --git a/modules/structs/org.go b/modules/structs/org.go index 4b70cae78cae3..504a3ac5d5a33 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -24,6 +24,7 @@ type CreateOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` + // visibility can be "public" (default), "limited" or "private" // enum: public,limited,private Visibility string `json:"visibility" binding:"In(,public,limited,private)"` } @@ -34,6 +35,7 @@ type EditOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` + // visibility can be "public", "limited" or "private" // enum: public,limited,private Visibility string `json:"visibility" binding:"In(,public,limited,private)"` } diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index ac8b9333fe57c..4387e84808b42 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -7,29 +7,41 @@ package structs // FileOptions options for all file APIs type FileOptions struct { - Message string `json:"message" binding:"Required"` - BranchName string `json:"branch"` + // message (optional) for the commit of this file. if not supplied, default create/update file message will be used + Message string `json:"message" binding:"Required"` + // branch (optional) to base this file from. if not given, the default branch is used + BranchName string `json:"branch"` + // new_branch (optional) will make a new branch from 'branch' before creating the file NewBranchName string `json:"new_branch"` + // author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) Author Identity `json:"author"` - Committer Identity `json:"committer"` + Committer Identity `json:"committer"` } // CreateFileOptions options for creating files +// Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) type CreateFileOptions struct { FileOptions + // content must be base64 encoded Content string `json:"content"` } // DeleteFileOptions options for deleting files (used for other File structs below) +// Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) type DeleteFileOptions struct { FileOptions + // sha is the SHA for the file that already exists + // required: true SHA string `json:"sha" binding:"Required"` } // UpdateFileOptions options for updating files +// Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) type UpdateFileOptions struct { DeleteFileOptions + // content must be base64 encoded Content string `json:"content"` + // from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL FromPath string `json:"from_path" binding:"MaxSize(500)"` } diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 8b10f4eb2633d..d740647cd4f20 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -31,7 +31,6 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { // required: true // - name: organization // in: body - // description: "'visibility' can be \"public\", \"limited\" or \"private\"" // required: true // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 985c997d0b5f1..2893887a4bf14 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -75,7 +75,6 @@ func Create(ctx *context.APIContext, form api.CreateOrgOption) { // parameters: // - name: organization // in: body - // description: "'visibility' can be \"public\", \"limited\" or \"private\"" // required: true // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: @@ -160,7 +159,7 @@ func Edit(ctx *context.APIContext, form api.EditOrgOption) { // required: true // - name: body // in: body - // description: "'visibility' can be \"public\", \"limited\" or \"private\"" + // required: true // schema: // "$ref": "#/definitions/EditOrgOption" // responses: diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index db952263e2f23..20f80f37f4c67 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -181,7 +181,7 @@ func CreateFile(ctx *context.APIContext, apiOpts api.CreateFileOptions) { // required: true // - name: body // in: body - // description: "'content' must be base64 encoded\n\n 'author' and 'committer' are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)\n\n If 'branch' is not given, default branch will be used\n\n 'sha' is the SHA for the file that already exists\n\n 'new_branch' (optional) will make a new branch from 'branch' before creating the file" + // required: true // schema: // "$ref": "#/definitions/CreateFileOptions" // responses: @@ -238,7 +238,7 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) { // required: true // - name: body // in: body - // description: "'content' must be base64 encoded\n\n 'sha' is the SHA for the file that already exists\n\n 'author' and 'committer' are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)\n\n If 'branch' is not given, default branch will be used\n\n 'new_branch' (optional) will make a new branch from 'branch' before updating the file" + // required: true // schema: // "$ref": "#/definitions/UpdateFileOptions" // responses: @@ -316,7 +316,7 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) { // required: true // - name: body // in: body - // description: "'sha' is the SHA for the file to be deleted\n\n 'author' and 'committer' are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)\n\n If 'branch' is not given, default branch will be used\n\n 'new_branch' (optional) will make a new branch from 'branch' before deleting the file" + // required: true // schema: // "$ref": "#/definitions/DeleteFileOptions" // responses: diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index e7a7e6c3ac5f8..50cc93d0445e0 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -272,7 +272,6 @@ "required": true }, { - "description": "'visibility' can be \"public\", \"limited\" or \"private\"", "name": "organization", "in": "body", "required": true, @@ -460,7 +459,6 @@ "operationId": "orgCreate", "parameters": [ { - "description": "'visibility' can be \"public\", \"limited\" or \"private\"", "name": "organization", "in": "body", "required": true, @@ -552,9 +550,9 @@ "required": true }, { - "description": "'visibility' can be \"public\", \"limited\" or \"private\"", "name": "body", "in": "body", + "required": true, "schema": { "$ref": "#/definitions/EditOrgOption" } @@ -1607,9 +1605,9 @@ "required": true }, { - "description": "'content' must be base64 encoded\n\n 'sha' is the SHA for the file that already exists\n\n 'author' and 'committer' are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)\n\n If 'branch' is not given, default branch will be used\n\n 'new_branch' (optional) will make a new branch from 'branch' before updating the file", "name": "body", "in": "body", + "required": true, "schema": { "$ref": "#/definitions/UpdateFileOptions" } @@ -1656,9 +1654,9 @@ "required": true }, { - "description": "'content' must be base64 encoded\n\n 'author' and 'committer' are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)\n\n If 'branch' is not given, default branch will be used\n\n 'sha' is the SHA for the file that already exists\n\n 'new_branch' (optional) will make a new branch from 'branch' before creating the file", "name": "body", "in": "body", + "required": true, "schema": { "$ref": "#/definitions/CreateFileOptions" } @@ -1705,9 +1703,9 @@ "required": true }, { - "description": "'sha' is the SHA for the file to be deleted\n\n 'author' and 'committer' are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)\n\n If 'branch' is not given, default branch will be used\n\n 'new_branch' (optional) will make a new branch from 'branch' before deleting the file", "name": "body", "in": "body", + "required": true, "schema": { "$ref": "#/definitions/DeleteFileOptions" } @@ -6887,13 +6885,14 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateFileOptions": { - "description": "CreateFileOptions options for creating files", + "description": "CreateFileOptions options for creating files\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", "properties": { "author": { "$ref": "#/definitions/Identity" }, "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", "type": "string", "x-go-name": "BranchName" }, @@ -6901,14 +6900,17 @@ "$ref": "#/definitions/Identity" }, "content": { + "description": "content must be base64 encoded", "type": "string", "x-go-name": "Content" }, "message": { + "description": "message (optional) for the commit of this file. if not supplied, default create/update file message will be used", "type": "string", "x-go-name": "Message" }, "new_branch": { + "description": "new_branch (optional) will make a new branch from 'branch' before creating the file", "type": "string", "x-go-name": "NewBranchName" } @@ -7143,6 +7145,7 @@ "x-go-name": "UserName" }, "visibility": { + "description": "visibility can be \"public\" (default), \"limited\" or \"private\"", "type": "string", "enum": [ "public", @@ -7417,13 +7420,17 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "DeleteFileOptions": { - "description": "DeleteFileOptions options for deleting files (used for other File structs below)", + "description": "DeleteFileOptions options for deleting files (used for other File structs below)\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", + "required": [ + "sha" + ], "properties": { "author": { "$ref": "#/definitions/Identity" }, "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", "type": "string", "x-go-name": "BranchName" }, @@ -7431,14 +7438,17 @@ "$ref": "#/definitions/Identity" }, "message": { + "description": "message (optional) for the commit of this file. if not supplied, default create/update file message will be used", "type": "string", "x-go-name": "Message" }, "new_branch": { + "description": "new_branch (optional) will make a new branch from 'branch' before creating the file", "type": "string", "x-go-name": "NewBranchName" }, "sha": { + "description": "sha is the SHA for the file that already exists", "type": "string", "x-go-name": "SHA" } @@ -7662,6 +7672,7 @@ "x-go-name": "Location" }, "visibility": { + "description": "visibility can be \"public\", \"limited\" or \"private\"", "type": "string", "enum": [ "public", @@ -9391,13 +9402,17 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "UpdateFileOptions": { - "description": "UpdateFileOptions options for updating files", + "description": "UpdateFileOptions options for updating files\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", + "required": [ + "sha" + ], "properties": { "author": { "$ref": "#/definitions/Identity" }, "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", "type": "string", "x-go-name": "BranchName" }, @@ -9405,22 +9420,27 @@ "$ref": "#/definitions/Identity" }, "content": { + "description": "content must be base64 encoded", "type": "string", "x-go-name": "Content" }, "from_path": { + "description": "from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL", "type": "string", "x-go-name": "FromPath" }, "message": { + "description": "message (optional) for the commit of this file. if not supplied, default create/update file message will be used", "type": "string", "x-go-name": "Message" }, "new_branch": { + "description": "new_branch (optional) will make a new branch from 'branch' before creating the file", "type": "string", "x-go-name": "NewBranchName" }, "sha": { + "description": "sha is the SHA for the file that already exists", "type": "string", "x-go-name": "SHA" } From 55d16f14d4d96cec18d961116a30622eaec13e25 Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Tue, 28 May 2019 10:26:40 -0400 Subject: [PATCH 08/11] Adds required property to the content field of create and update repo file --- modules/structs/repo_file.go | 2 ++ templates/swagger/v1_json.tmpl | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index 4387e84808b42..1e0c11473ce04 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -23,6 +23,7 @@ type FileOptions struct { type CreateFileOptions struct { FileOptions // content must be base64 encoded + // required: true Content string `json:"content"` } @@ -40,6 +41,7 @@ type DeleteFileOptions struct { type UpdateFileOptions struct { DeleteFileOptions // content must be base64 encoded + // required: true Content string `json:"content"` // from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL FromPath string `json:"from_path" binding:"MaxSize(500)"` diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 50cc93d0445e0..4ef10db99ee34 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -6887,6 +6887,9 @@ "CreateFileOptions": { "description": "CreateFileOptions options for creating files\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", + "required": [ + "content" + ], "properties": { "author": { "$ref": "#/definitions/Identity" @@ -9405,7 +9408,8 @@ "description": "UpdateFileOptions options for updating files\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", "required": [ - "sha" + "sha", + "content" ], "properties": { "author": { From 5f7a8c9d0ec8695e2c09a0e126616003bd205deb Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Tue, 28 May 2019 10:34:05 -0400 Subject: [PATCH 09/11] Update the message comment --- modules/structs/repo_file.go | 2 +- templates/swagger/v1_json.tmpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index 1e0c11473ce04..52874d90c0205 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -7,7 +7,7 @@ package structs // FileOptions options for all file APIs type FileOptions struct { - // message (optional) for the commit of this file. if not supplied, default create/update file message will be used + // message (optional) for the commit of this file. if not supplied, a default message will be used Message string `json:"message" binding:"Required"` // branch (optional) to base this file from. if not given, the default branch is used BranchName string `json:"branch"` diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 4ef10db99ee34..5f9211125cc29 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -6908,7 +6908,7 @@ "x-go-name": "Content" }, "message": { - "description": "message (optional) for the commit of this file. if not supplied, default create/update file message will be used", + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", "type": "string", "x-go-name": "Message" }, @@ -7441,7 +7441,7 @@ "$ref": "#/definitions/Identity" }, "message": { - "description": "message (optional) for the commit of this file. if not supplied, default create/update file message will be used", + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", "type": "string", "x-go-name": "Message" }, @@ -9434,7 +9434,7 @@ "x-go-name": "FromPath" }, "message": { - "description": "message (optional) for the commit of this file. if not supplied, default create/update file message will be used", + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", "type": "string", "x-go-name": "Message" }, From 901f63997712f54e19b91883c201511c64c2654a Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Tue, 28 May 2019 11:11:55 -0400 Subject: [PATCH 10/11] Uses back ticks to better show fields and values for swagger --- modules/structs/org.go | 4 ++-- modules/structs/repo_file.go | 10 +++++----- templates/swagger/v1_json.tmpl | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/structs/org.go b/modules/structs/org.go index 504a3ac5d5a33..08ab139975283 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -24,7 +24,7 @@ type CreateOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` - // visibility can be "public" (default), "limited" or "private" + // possible values are `public` (default), `limited` or `private` // enum: public,limited,private Visibility string `json:"visibility" binding:"In(,public,limited,private)"` } @@ -35,7 +35,7 @@ type EditOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` - // visibility can be "public", "limited" or "private" + // possible values are `public`, `limited` or `private` // enum: public,limited,private Visibility string `json:"visibility" binding:"In(,public,limited,private)"` } diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index 52874d90c0205..3b8e5c76fd109 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -11,15 +11,15 @@ type FileOptions struct { Message string `json:"message" binding:"Required"` // branch (optional) to base this file from. if not given, the default branch is used BranchName string `json:"branch"` - // new_branch (optional) will make a new branch from 'branch' before creating the file + // new_branch (optional) will make a new branch from `branch` before creating the file NewBranchName string `json:"new_branch"` - // author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + // `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) Author Identity `json:"author"` Committer Identity `json:"committer"` } // CreateFileOptions options for creating files -// Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) type CreateFileOptions struct { FileOptions // content must be base64 encoded @@ -28,7 +28,7 @@ type CreateFileOptions struct { } // DeleteFileOptions options for deleting files (used for other File structs below) -// Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) type DeleteFileOptions struct { FileOptions // sha is the SHA for the file that already exists @@ -37,7 +37,7 @@ type DeleteFileOptions struct { } // UpdateFileOptions options for updating files -// Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) type UpdateFileOptions struct { DeleteFileOptions // content must be base64 encoded diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 5f9211125cc29..7bfb069c94f23 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -6885,7 +6885,7 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateFileOptions": { - "description": "CreateFileOptions options for creating files\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "description": "CreateFileOptions options for creating files\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", "required": [ "content" @@ -6913,7 +6913,7 @@ "x-go-name": "Message" }, "new_branch": { - "description": "new_branch (optional) will make a new branch from 'branch' before creating the file", + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", "type": "string", "x-go-name": "NewBranchName" } @@ -7148,7 +7148,7 @@ "x-go-name": "UserName" }, "visibility": { - "description": "visibility can be \"public\" (default), \"limited\" or \"private\"", + "description": "possible values are `public` (default), `limited` or `private`", "type": "string", "enum": [ "public", @@ -7423,7 +7423,7 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "DeleteFileOptions": { - "description": "DeleteFileOptions options for deleting files (used for other File structs below)\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "description": "DeleteFileOptions options for deleting files (used for other File structs below)\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", "required": [ "sha" @@ -7446,7 +7446,7 @@ "x-go-name": "Message" }, "new_branch": { - "description": "new_branch (optional) will make a new branch from 'branch' before creating the file", + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", "type": "string", "x-go-name": "NewBranchName" }, @@ -7675,7 +7675,7 @@ "x-go-name": "Location" }, "visibility": { - "description": "visibility can be \"public\", \"limited\" or \"private\"", + "description": "possible values are `public`, `limited` or `private`", "type": "string", "enum": [ "public", @@ -9405,7 +9405,7 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "UpdateFileOptions": { - "description": "UpdateFileOptions options for updating files\nNote: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "description": "UpdateFileOptions options for updating files\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", "type": "object", "required": [ "sha", @@ -9439,7 +9439,7 @@ "x-go-name": "Message" }, "new_branch": { - "description": "new_branch (optional) will make a new branch from 'branch' before creating the file", + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", "type": "string", "x-go-name": "NewBranchName" }, From 7e33e610abe9017d769fd29ad6774ac0a1a9646d Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Tue, 28 May 2019 11:17:33 -0400 Subject: [PATCH 11/11] Fmt fix --- modules/structs/repo_file.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index 3b8e5c76fd109..c447d267244c9 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -12,9 +12,9 @@ type FileOptions struct { // branch (optional) to base this file from. if not given, the default branch is used BranchName string `json:"branch"` // new_branch (optional) will make a new branch from `branch` before creating the file - NewBranchName string `json:"new_branch"` + NewBranchName string `json:"new_branch"` // `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) - Author Identity `json:"author"` + Author Identity `json:"author"` Committer Identity `json:"committer"` } @@ -42,7 +42,7 @@ type UpdateFileOptions struct { DeleteFileOptions // content must be base64 encoded // required: true - Content string `json:"content"` + Content string `json:"content"` // from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL FromPath string `json:"from_path" binding:"MaxSize(500)"` }