Skip to content

Commit 8c8471e

Browse files
authored
Addition to (Add Location, Website and Description to API #15675) (#15690)
* Use same name as other structs. * Sync with normal forms. * Edit description with API. * Workaround for nil value.
1 parent 0590176 commit 8c8471e

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

modules/structs/admin_user.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ type EditUserOption struct {
3232
FullName *string `json:"full_name" binding:"MaxSize(100)"`
3333
Password string `json:"password" binding:"MaxSize(255)"`
3434
MustChangePassword *bool `json:"must_change_password"`
35-
Website *string `json:"website" binding:"MaxSize(50)"`
35+
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
3636
Location *string `json:"location" binding:"MaxSize(50)"`
37+
Description *string `json:"description" binding:"MaxSize(255)"`
3738
Active *bool `json:"active"`
3839
Admin *bool `json:"admin"`
3940
AllowGitHook *bool `json:"allow_git_hook"`

modules/structs/org.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ type CreateOrgOption struct {
2222
// required: true
2323
UserName string `json:"username" binding:"Required"`
2424
FullName string `json:"full_name"`
25-
Description string `json:"description"`
26-
Website string `json:"website"`
27-
Location string `json:"location"`
25+
Description string `json:"description" binding:"MaxSize(255)"`
26+
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
27+
Location string `json:"location" binding:"MaxSize(50)"`
2828
// possible values are `public` (default), `limited` or `private`
2929
// enum: public,limited,private
3030
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
@@ -34,9 +34,9 @@ type CreateOrgOption struct {
3434
// EditOrgOption options for editing an organization
3535
type EditOrgOption struct {
3636
FullName string `json:"full_name"`
37-
Description string `json:"description"`
38-
Website string `json:"website"`
39-
Location string `json:"location"`
37+
Description string `json:"description" binding:"MaxSize(255)"`
38+
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
39+
Location string `json:"location" binding:"MaxSize(50)"`
4040
// possible values are `public`, `limited` or `private`
4141
// enum: public,limited,private
4242
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`

modules/structs/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ type User struct {
3737
Location string `json:"location"`
3838
// the user's website
3939
Website string `json:"website"`
40-
// the user's biography
41-
Description string `json:"bio"`
40+
// the user's description
41+
Description string `json:"description"`
4242
}
4343

4444
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility

routers/api/v1/admin/user.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func EditUser(ctx *context.APIContext) {
203203
if form.Location != nil {
204204
u.Location = *form.Location
205205
}
206+
if form.Description != nil {
207+
u.Description = *form.Description
208+
}
206209
if form.Active != nil {
207210
u.IsActive = *form.Active
208211
}

templates/swagger/v1_json.tmpl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13800,6 +13800,10 @@
1380013800
"type": "boolean",
1380113801
"x-go-name": "AllowImportLocal"
1380213802
},
13803+
"description": {
13804+
"type": "string",
13805+
"x-go-name": "Description"
13806+
},
1380313807
"email": {
1380413808
"type": "string",
1380513809
"format": "email",
@@ -16251,16 +16255,16 @@
1625116255
"type": "string",
1625216256
"x-go-name": "AvatarURL"
1625316257
},
16254-
"bio": {
16255-
"description": "the user's biography",
16256-
"type": "string",
16257-
"x-go-name": "Description"
16258-
},
1625916258
"created": {
1626016259
"type": "string",
1626116260
"format": "date-time",
1626216261
"x-go-name": "Created"
1626316262
},
16263+
"description": {
16264+
"description": "the user's description",
16265+
"type": "string",
16266+
"x-go-name": "Description"
16267+
},
1626416268
"email": {
1626516269
"type": "string",
1626616270
"format": "email",

0 commit comments

Comments
 (0)