Skip to content

Commit

Permalink
add omitempty to json tag for struct fields that are optional (#314)
Browse files Browse the repository at this point in the history
* add omitempty to json attribute options struct field that are optional

* remove omitempty from required fields
  • Loading branch information
uturunku1 authored and sebasslash committed Feb 22, 2022
1 parent c6350b8 commit 43dbdec
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions admin_user.go
Expand Up @@ -81,10 +81,10 @@ type AdminUserListOptions struct {
Query string `url:"q,omitempty"`

// Can be "true" or "false" to show only administrators or non-administrators.
Administrators string `url:"filter[admin]"`
Administrators string `url:"filter[admin],omitempty"`

// Can be "true" or "false" to show only suspended users or users who are not suspended.
SuspendedUsers string `url:"filter[suspended]"`
SuspendedUsers string `url:"filter[suspended],omitempty"`

Include []AdminUserIncludeOps `url:"include,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion oauth_token.go
Expand Up @@ -109,7 +109,7 @@ type OAuthTokenUpdateOptions struct {
Type string `jsonapi:"primary,oauth-tokens"`

// A private SSH key to be used for git clone operations.
PrivateSSHKey *string `jsonapi:"attr,ssh-key"`
PrivateSSHKey *string `jsonapi:"attr,ssh-key,omitempty"`
}

// Update an existing OAuth token.
Expand Down
2 changes: 1 addition & 1 deletion policy.go
Expand Up @@ -127,7 +127,7 @@ type PolicyCreateOptions struct {

// EnforcementOptions represents the enforcement options of a policy.
type EnforcementOptions struct {
Path *string `json:"path,omitempty"`
Path *string `json:"path"`
Mode *EnforcementLevel `json:"mode"`
}

Expand Down
2 changes: 1 addition & 1 deletion state_version.go
Expand Up @@ -131,7 +131,7 @@ type StateVersionCreateOptions struct {

// Force can be set to skip certain validations. Wrong use
// of this flag can cause data loss, so USE WITH CAUTION!
Force *bool `jsonapi:"attr,force"`
Force *bool `jsonapi:"attr,force,omitempty"`

// Specifies the run to associate the state with.
Run *Run `jsonapi:"relation,run,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion team_access.go
Expand Up @@ -103,7 +103,7 @@ type TeamAccess struct {
// TeamAccessListOptions represents the options for listing team accesses.
type TeamAccessListOptions struct {
ListOptions
WorkspaceID string `url:"filter[workspace][id],omitempty"`
WorkspaceID string `url:"filter[workspace][id]"`
}

//check that workspaceID field has a valid value
Expand Down

0 comments on commit 43dbdec

Please sign in to comment.