Skip to content

Commit e5df91b

Browse files
refactor: Pass required Projects v2 fields by value
Per review, required request-body fields should not be pointers. The OpenAPI required arrays mark title (draft create) and name/layout (view create) as required, and a single-select option's name is its required display label, so make those non-pointer values without omitempty. AddProjectV2FieldRequest stays all-pointer because its fields are required only conditionally (the body is a oneOf), as do the optional fields and the response types.
1 parent 75c7c47 commit e5df91b

4 files changed

Lines changed: 27 additions & 39 deletions

File tree

‎github/github-accessors.go‎

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎github/github-accessors_test.go‎

Lines changed: 4 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎github/projects.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ func (s *ProjectsService) DeleteUserProjectItem(ctx context.Context, username st
733733
// CreateProjectV2DraftItemRequest specifies the parameters to create a draft item in a project.
734734
type CreateProjectV2DraftItemRequest struct {
735735
// Title is the title of the draft issue item to create. (Required.)
736-
Title *string `json:"title,omitempty"`
736+
Title string `json:"title"`
737737
// Body is the body content of the draft issue item to create. (Optional.)
738738
Body *string `json:"body,omitempty"`
739739
}
@@ -786,7 +786,7 @@ func (s *ProjectsService) CreateUserProjectDraftItem(ctx context.Context, userID
786786
// ProjectV2FieldSingleSelectOption represents an option to create for a single_select project field.
787787
type ProjectV2FieldSingleSelectOption struct {
788788
// Name is the display name of the option. (Required.)
789-
Name *string `json:"name,omitempty"`
789+
Name string `json:"name"`
790790
// Color is the color associated with the option.
791791
// One of: BLUE, GRAY, GREEN, ORANGE, PINK, PURPLE, RED, YELLOW.
792792
Color *string `json:"color,omitempty"`
@@ -952,9 +952,9 @@ func (s ProjectV2ViewSortBy) MarshalJSON() ([]byte, error) {
952952
// CreateProjectV2ViewRequest specifies the parameters to create a project view.
953953
type CreateProjectV2ViewRequest struct {
954954
// Name is the view's display name. (Required.)
955-
Name *string `json:"name,omitempty"`
955+
Name string `json:"name"`
956956
// Layout is the view's layout. One of: table, board, roadmap. (Required.)
957-
Layout *string `json:"layout,omitempty"`
957+
Layout string `json:"layout"`
958958
// Filter is an optional query string to filter the items shown in the view.
959959
Filter *string `json:"filter,omitempty"`
960960
// VisibleFields lists the field IDs to display. Not applicable to the roadmap layout.

‎github/projects_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ func TestProjectsService_CreateOrganizationProjectDraftItem(t *testing.T) {
15061506
t.Parallel()
15071507
client, mux, _ := setup(t)
15081508

1509-
input := CreateProjectV2DraftItemRequest{Title: Ptr("My draft"), Body: Ptr("Draft body")}
1509+
input := CreateProjectV2DraftItemRequest{Title: "My draft", Body: Ptr("Draft body")}
15101510

15111511
mux.HandleFunc("/orgs/o/projectsV2/1/drafts", func(w http.ResponseWriter, r *http.Request) {
15121512
testMethod(t, r, "POST")
@@ -1541,7 +1541,7 @@ func TestProjectsService_CreateUserProjectDraftItem(t *testing.T) {
15411541
t.Parallel()
15421542
client, mux, _ := setup(t)
15431543

1544-
input := CreateProjectV2DraftItemRequest{Title: Ptr("My draft")}
1544+
input := CreateProjectV2DraftItemRequest{Title: "My draft"}
15451545

15461546
mux.HandleFunc("/user/12345/projectsV2/1/drafts", func(w http.ResponseWriter, r *http.Request) {
15471547
testMethod(t, r, "POST")
@@ -1576,8 +1576,8 @@ func TestProjectsService_AddOrganizationProjectField(t *testing.T) {
15761576
Name: Ptr("Priority"),
15771577
DataType: Ptr("single_select"),
15781578
SingleSelectOptions: []*ProjectV2FieldSingleSelectOption{
1579-
{Name: Ptr("High"), Color: Ptr("RED"), Description: Ptr("Urgent")},
1580-
{Name: Ptr("Low"), Color: Ptr("GRAY")},
1579+
{Name: "High", Color: Ptr("RED"), Description: Ptr("Urgent")},
1580+
{Name: "Low", Color: Ptr("GRAY")},
15811581
},
15821582
}
15831583

@@ -1660,8 +1660,8 @@ func TestProjectsService_CreateOrganizationProjectView(t *testing.T) {
16601660
client, mux, _ := setup(t)
16611661

16621662
input := CreateProjectV2ViewRequest{
1663-
Name: Ptr("My board"),
1664-
Layout: Ptr("board"),
1663+
Name: "My board",
1664+
Layout: "board",
16651665
Filter: Ptr("is:open"),
16661666
VisibleFields: []int64{1, 2, 3},
16671667
}
@@ -1716,7 +1716,7 @@ func TestProjectsService_CreateUserProjectView(t *testing.T) {
17161716
t.Parallel()
17171717
client, mux, _ := setup(t)
17181718

1719-
input := CreateProjectV2ViewRequest{Name: Ptr("My table"), Layout: Ptr("table")}
1719+
input := CreateProjectV2ViewRequest{Name: "My table", Layout: "table"}
17201720

17211721
mux.HandleFunc("/users/12345/projectsV2/1/views", func(w http.ResponseWriter, r *http.Request) {
17221722
testMethod(t, r, "POST")

0 commit comments

Comments
 (0)