Skip to content

Commit c988603

Browse files
committed
cleanup
Signed-off-by: Pierre Fenoll <[email protected]>
1 parent f08d80d commit c988603

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

openapi3/schema.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ func (schema *Schema) UnmarshalJSON(data []byte) error {
377377
delete(x.Extensions, "example")
378378
delete(x.Extensions, "externalDocs")
379379

380-
// Array-related, here for struct compactness
380+
// Array-related
381381
delete(x.Extensions, "uniqueItems")
382-
// Number-related, here for struct compactness
382+
// Number-related
383383
delete(x.Extensions, "exclusiveMinimum")
384384
delete(x.Extensions, "exclusiveMaximum")
385385
// Properties
@@ -792,6 +792,7 @@ func (schema *Schema) WithAdditionalProperties(v *Schema) *Schema {
792792
return schema
793793
}
794794

795+
// IsEmpty tells whether schema is equivalent to the empty schema `{}`.
795796
func (schema *Schema) IsEmpty() bool {
796797
if schema.Type != "" || schema.Format != "" || len(schema.Enum) != 0 ||
797798
schema.UniqueItems || schema.ExclusiveMin || schema.ExclusiveMax ||
@@ -806,10 +807,10 @@ func (schema *Schema) IsEmpty() bool {
806807
if n := schema.Not; n != nil && !n.Value.IsEmpty() {
807808
return false
808809
}
809-
if ap := schema.AdditionalProperties.Schema; ap != nil {
810+
if ap := schema.AdditionalProperties.Schema; ap != nil && !ap.Value.IsEmpty() {
810811
return false
811812
}
812-
if apa := schema.AdditionalProperties.Has; apa != nil && !*apa {
813+
if apa := schema.AdditionalProperties.Has; apa != nil && *apa {
813814
return false
814815
}
815816
if items := schema.Items; items != nil && !items.Value.IsEmpty() {

0 commit comments

Comments
 (0)