File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ package openapi3
2+
3+ import (
4+ "encoding/json"
5+ "testing"
6+
7+ "github.com/stretchr/testify/require"
8+ )
9+
10+ func TestIssue746 (t * testing.T ) {
11+ schema := & Schema {}
12+ err := schema .UnmarshalJSON ([]byte (`{"additionalProperties": false}` ))
13+ require .NoError (t , err )
14+
15+ var value interface {}
16+ err = json .Unmarshal ([]byte (`{"foo": "bar"}` ), & value )
17+ require .NoError (t , err )
18+
19+ err = schema .VisitJSON (value )
20+ require .Error (t , err )
21+
22+ schemaErr := & SchemaError {}
23+ require .ErrorAs (t , err , & schemaErr )
24+ require .Equal (t , "properties" , schemaErr .SchemaField )
25+ require .Equal (t , `property "foo" is unsupported` , schemaErr .Reason )
26+ }
Original file line number Diff line number Diff line change @@ -810,7 +810,7 @@ func (schema *Schema) IsEmpty() bool {
810810 if ap := schema .AdditionalProperties .Schema ; ap != nil && ! ap .Value .IsEmpty () {
811811 return false
812812 }
813- if apa := schema .AdditionalProperties .Has ; apa != nil && * apa {
813+ if apa := schema .AdditionalProperties .Has ; apa != nil && ! * apa {
814814 return false
815815 }
816816 if items := schema .Items ; items != nil && ! items .Value .IsEmpty () {
You can’t perform that action at this time.
0 commit comments