diff --git a/fixtures/allow_additional_props.json b/fixtures/allow_additional_props.json index 20d58fb..7c4e5e4 100644 --- a/fixtures/allow_additional_props.json +++ b/fixtures/allow_additional_props.json @@ -67,10 +67,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/defaults_expanded_toplevel.json b/fixtures/defaults_expanded_toplevel.json index ca43057..f66be7d 100644 --- a/fixtures/defaults_expanded_toplevel.json +++ b/fixtures/defaults_expanded_toplevel.json @@ -67,10 +67,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/go_comments.json b/fixtures/go_comments.json index 6b3fb29..2e675cc 100644 --- a/fixtures/go_comments.json +++ b/fixtures/go_comments.json @@ -4,10 +4,8 @@ "$ref": "#/$defs/User", "$defs": { "NamedPets": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/Pet" - } + "additionalProperties": { + "$ref": "#/$defs/Pet" }, "type": "object", "description": "NamedPets is a map of animal names to pets." diff --git a/fixtures/ignore_type.json b/fixtures/ignore_type.json index 383e7ab..76c9d9b 100644 --- a/fixtures/ignore_type.json +++ b/fixtures/ignore_type.json @@ -61,10 +61,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/no_reference.json b/fixtures/no_reference.json index 67b2e19..f6935d7 100644 --- a/fixtures/no_reference.json +++ b/fixtures/no_reference.json @@ -55,10 +55,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/no_reference_anchor.json b/fixtures/no_reference_anchor.json index a6a6e42..2076e36 100644 --- a/fixtures/no_reference_anchor.json +++ b/fixtures/no_reference_anchor.json @@ -57,10 +57,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/required_from_jsontags.json b/fixtures/required_from_jsontags.json index af71f1d..2f14e89 100644 --- a/fixtures/required_from_jsontags.json +++ b/fixtures/required_from_jsontags.json @@ -68,10 +68,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/test_user.json b/fixtures/test_user.json index 43ad542..76ba59b 100644 --- a/fixtures/test_user.json +++ b/fixtures/test_user.json @@ -68,10 +68,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/fixtures/test_user_assign_anchor.json b/fixtures/test_user_assign_anchor.json index 8031188..2b85ca5 100644 --- a/fixtures/test_user_assign_anchor.json +++ b/fixtures/test_user_assign_anchor.json @@ -70,10 +70,8 @@ "description": "list of IDs, omitted when empty" }, "tags": { - "patternProperties": { - ".*": { - "type": "string" - } + "additionalProperties": { + "type": "string" }, "type": "object" }, diff --git a/reflect.go b/reflect.go index 1b6732d..6bc27a1 100644 --- a/reflect.go +++ b/reflect.go @@ -464,9 +464,7 @@ func (r *Reflector) reflectMap(definitions Definitions, t reflect.Type, st *Sche return } if t.Elem().Kind() != reflect.Interface { - st.PatternProperties = map[string]*Schema{ - ".*": r.refOrReflectTypeToSchema(definitions, t.Elem()), - } + st.AdditionalProperties = r.refOrReflectTypeToSchema(definitions, t.Elem()) } } @@ -491,7 +489,7 @@ func (r *Reflector) reflectStruct(definitions Definitions, t reflect.Type, s *Sc if r.AssignAnchor { s.Anchor = t.Name() } - if !r.AllowAdditionalProperties { + if !r.AllowAdditionalProperties && s.AdditionalProperties == nil { s.AdditionalProperties = FalseSchema }