Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name field for org api #21270

Merged
merged 8 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func ToOrganization(org *organization.Organization) *api.Organization {
return &api.Organization{
ID: org.ID,
AvatarURL: org.AsUser().AvatarLink(),
Name: org.Name,
UserName: org.Name,
FullName: org.FullName,
Description: org.Description,
Expand Down
4 changes: 3 additions & 1 deletion modules/structs/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ package structs
// Organization represents an organization
type Organization struct {
ID int64 `json:"id"`
UserName string `json:"username"`
Name string `json:"name"`
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"`
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
// deprecated
UserName string `json:"username"`
}

// OrganizationPermissions list different users permissions on an organization
Expand Down
5 changes: 5 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17326,11 +17326,16 @@
"type": "string",
"x-go-name": "Location"
},
"name": {
"type": "string",
"x-go-name": "Name"
},
"repo_admin_change_team_access": {
"type": "boolean",
"x-go-name": "RepoAdminChangeTeamAccess"
},
"username": {
"description": "deprecated",
"type": "string",
"x-go-name": "UserName"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api_admin_org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAPIAdminOrgCreate(t *testing.T) {
var apiOrg api.Organization
DecodeJSON(t, resp, &apiOrg)

assert.Equal(t, org.UserName, apiOrg.UserName)
assert.Equal(t, org.UserName, apiOrg.Name)
assert.Equal(t, org.FullName, apiOrg.FullName)
assert.Equal(t, org.Description, apiOrg.Description)
assert.Equal(t, org.Website, apiOrg.Website)
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/api_org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAPIOrgCreate(t *testing.T) {
var apiOrg api.Organization
DecodeJSON(t, resp, &apiOrg)

assert.Equal(t, org.UserName, apiOrg.UserName)
assert.Equal(t, org.UserName, apiOrg.Name)
assert.Equal(t, org.FullName, apiOrg.FullName)
assert.Equal(t, org.Description, apiOrg.Description)
assert.Equal(t, org.Website, apiOrg.Website)
Expand All @@ -54,7 +54,7 @@ func TestAPIOrgCreate(t *testing.T) {
req = NewRequestf(t, "GET", "/api/v1/orgs/%s?token=%s", org.UserName, token)
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiOrg)
assert.EqualValues(t, org.UserName, apiOrg.UserName)
assert.EqualValues(t, org.UserName, apiOrg.Name)

req = NewRequestf(t, "GET", "/api/v1/orgs/%s/repos?token=%s", org.UserName, token)
resp = MakeRequest(t, req, http.StatusOK)
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestAPIOrgEdit(t *testing.T) {
var apiOrg api.Organization
DecodeJSON(t, resp, &apiOrg)

assert.Equal(t, "user3", apiOrg.UserName)
assert.Equal(t, "user3", apiOrg.Name)
assert.Equal(t, org.FullName, apiOrg.FullName)
assert.Equal(t, org.Description, apiOrg.Description)
assert.Equal(t, org.Website, apiOrg.Website)
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/api_user_orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestUserOrgs(t *testing.T) {
assert.Equal(t, []*api.Organization{
{
ID: 17,
Name: user17.Name,
UserName: user17.Name,
FullName: user17.FullName,
AvatarURL: user17.AvatarLink(),
Expand All @@ -42,6 +43,7 @@ func TestUserOrgs(t *testing.T) {
},
{
ID: 3,
Name: user3.Name,
UserName: user3.Name,
FullName: user3.FullName,
AvatarURL: user3.AvatarLink(),
Expand Down Expand Up @@ -99,6 +101,7 @@ func TestMyOrgs(t *testing.T) {
assert.Equal(t, []*api.Organization{
{
ID: 17,
Name: user17.Name,
UserName: user17.Name,
FullName: user17.FullName,
AvatarURL: user17.AvatarLink(),
Expand All @@ -109,6 +112,7 @@ func TestMyOrgs(t *testing.T) {
},
{
ID: 3,
Name: user3.Name,
UserName: user3.Name,
FullName: user3.FullName,
AvatarURL: user3.AvatarLink(),
Expand Down