We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6f21afd commit 054ec33Copy full SHA for 054ec33
samples/client/petstore/go/model_test.go
@@ -0,0 +1,21 @@
1
+package main
2
+
3
+import (
4
+ "testing"
5
6
+ sw "github.com/OpenAPITools/openapi-generator/samples/client/petstore/go/go-petstore"
7
8
+ "github.com/stretchr/testify/assert"
9
+)
10
11
+func TestRequiredFieldsWithAdditionalPropertiesFalse(t *testing.T) {
12
+ assert := assert.New(t)
13
14
+ newAnimal := (sw.Animal{})
15
+ jsonAnimal := `{"className":"invalidAnimal","extraThing":"foo"}`
16
17
+ err := newAnimal.UnmarshalJSON([]byte(jsonAnimal))
18
+ expected := "json: unknown field \"extraThing\""
19
20
+ assert.ErrorContains(err, expected, "Animal should return error when missing additional fields are present")
21
+}
0 commit comments