Skip to content

Commit

Permalink
feat(java) handle null and missing values
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierapivideo authored Jan 12, 2022
1 parent b1676fb commit afacd2d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 11 deletions.
1 change: 1 addition & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9268,6 +9268,7 @@ components:
video.
example: pl4k0jvEUuaTdRAEjQ4Jfrgz
type: string
x-optional-nullable: true
title:
description: The title you want to use for your video.
type: string
Expand Down
28 changes: 27 additions & 1 deletion api_videos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var videoUpdateStruct = VideoUpdatePayload{
Description: PtrString("An amazing video explaining the string theory"),
Public: PtrBool(true),
Panoramic: PtrBool(false),
PlayerId: PtrString("pl45KFKdlddgk654dspkze"),
PlayerId: PtrNullableString("pl45KFKdlddgk654dspkze"),
Tags: &[]string{"maths", "string theory", "video"},
Metadata: &[]Metadata{
{
Expand Down Expand Up @@ -610,6 +610,32 @@ func TestVideos_Update(t *testing.T) {
}
}

func TestVideosUpdate_MarshalPlayerId(t *testing.T) {
if data, err := json.Marshal(VideoUpdatePayload{PlayerId: nil}); err != nil {
panic(err)
} else {
if strings.Compare(string(data), "{}") != 0 {
t.Errorf("Empty playerId in video update payload not properly marshaled")
}
}

if data, err := json.Marshal(VideoUpdatePayload{PlayerId: PtrNullableStringNull()}); err != nil {
panic(err)
} else {
if strings.Compare(string(data), "{\"playerId\":null}") != 0 {
t.Errorf("Null playerId in video update payload not properly marshaled")
}
}

if data, err := json.Marshal(VideoUpdatePayload{PlayerId: PtrNullableString("aa")}); err != nil {
panic(err)
} else {
if strings.Compare(string(data), "{\"playerId\":\"aa\"}") != 0 {
t.Errorf("Defined playerId in video update payload not properly marshaled")
}
}
}

func TestVideos_Delete(t *testing.T) {
setup()
defer teardown()
Expand Down
12 changes: 11 additions & 1 deletion docs/VideoUpdatePayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**PlayerId** | Pointer to **string** | The unique ID for the player you want to associate with your video. | [optional]
**PlayerId** | Pointer to **NullableString** | The unique ID for the player you want to associate with your video. | [optional]
**Title** | Pointer to **string** | The title you want to use for your video. | [optional]
**Description** | Pointer to **string** | A brief description of the video. | [optional]
**Public** | Pointer to **bool** | Whether the video is publicly available or not. False means it is set to private. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). | [optional]
Expand Down Expand Up @@ -57,6 +57,16 @@ SetPlayerId sets PlayerId field to given value.

HasPlayerId returns a boolean if a field has been set.

### SetPlayerIdNil

`func (o *VideoUpdatePayload) SetPlayerIdNil(b bool)`

SetPlayerIdNil sets the value for PlayerId to be an explicit nil

### UnsetPlayerId
`func (o *VideoUpdatePayload) UnsetPlayerId()`

UnsetPlayerId ensures that no value is present for PlayerId, not even an explicit nil
### GetTitle

`func (o *VideoUpdatePayload) GetTitle() string`
Expand Down
29 changes: 20 additions & 9 deletions model_video_update_payload.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit afacd2d

Please sign in to comment.