From c324e33ecf89198720324bb5c26a2380e71369df Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 3 May 2019 16:12:20 +0200 Subject: [PATCH] image.BufferView must be a pointer --- encode_test.go | 2 +- struct.go | 2 +- validator_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/encode_test.go b/encode_test.go index aa72529..fe7f0d9 100644 --- a/encode_test.go +++ b/encode_test.go @@ -82,7 +82,7 @@ func TestEncoder_Encode(t *testing.T) { {Extras: 8.0, Name: "cam_2", Perspective: &Perspective{Extras: 8.0, AspectRatio: 1, Yfov: 2, Zfar: 3, Znear: 4}}, }}}, false}, {"withImages", args{&Document{Images: []Image{ - {Extras: 8.0, Name: "binary", BufferView: 1, MimeType: "data:image/png"}, + {Extras: 8.0, Name: "binary", BufferView: Index(1), MimeType: "data:image/png"}, {Extras: 8.0, Name: "embedded", URI: "data:image/png;base64,dsjdsaGGUDXGA", MimeType: "data:image/png"}, {Extras: 8.0, Name: "external", URI: "https://web.com/a", MimeType: "data:image/png"}, }}}, false}, diff --git a/struct.go b/struct.go index eeb8456..5565f3f 100644 --- a/struct.go +++ b/struct.go @@ -607,7 +607,7 @@ type Image struct { Name string `json:"name,omitempty"` URI string `json:"uri,omitempty" validate:"omitempty"` MimeType string `json:"mimeType,omitempty" validate:"omitempty,oneof=image/jpeg image/png"` // Manadatory if BufferView is defined. - BufferView uint32 `json:"bufferView,omitempty"` // Use this instead of the image's uri property. + BufferView *uint32 `json:"bufferView,omitempty"` // Use this instead of the image's uri property. } // IsEmbeddedResource returns true if the buffer points to an embedded resource. diff --git a/validator_test.go b/validator_test.go index a8ad5a9..a324088 100644 --- a/validator_test.go +++ b/validator_test.go @@ -96,7 +96,7 @@ func TestValidateDocument(t *testing.T) { {"Document.Images[0].URI", &Document{Asset: Asset{Version: "1.0"}, Images: []Image{{URI: "a.png"}}}, false}, {"Document.Images[0].MimeType", &Document{Asset: Asset{Version: "1.0"}, - Images: []Image{{BufferView: 1}}}, true}, + Images: []Image{{BufferView: Index(1)}}}, true}, {"Document.Animations[0].Channels", &Document{Asset: Asset{Version: "1.0"}, Animations: []Animation{{Samplers: []AnimationSampler{{}}}}}, true}, {"Document.Animations[0].Channels[0].Target.Path", &Document{Asset: Asset{Version: "1.0"},