nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: marshmallow-code/apispec
Pull request #421 (2019-04-02 16:08:50)

Strip empty component sections from doc
This PR removes empty component subsections (parameters, responses, etc.) from the docs.

I'm tempted not to consider that a breaking change.


Patch:
diff --git a/src/apispec/core.py b/src/apispec/core.py
index 33304a8..23bd5a7 100644
--- a/src/apispec/core.py
+++ b/src/apispec/core.py
@@ -98,6 +98,7 @@ class Components(object):
         return {
             COMPONENT_SUBSECTIONS[self.openapi_version.major][k]: v
             for k, v in iteritems(subsections)
+            if v != {}
         }
 
     def schema(self, name, component=None, **kwargs):
@@ -245,7 +246,9 @@ class APISpec(object):
             ret.update(self.components.to_dict())
         else:
             ret["openapi"] = self.openapi_version.vstring
-            ret.update({"components": self.components.to_dict()})
+            components_dict = self.components.to_dict()
+            if components_dict:
+                ret["components"] = components_dict
         ret = deepupdate(ret, self.options)
         return ret
 


Test patch:
diff --git a/tests/test_ext_marshmallow.py b/tests/test_ext_marshmallow.py
index c1ffee1..906353b 100644
--- a/tests/test_ext_marshmallow.py
+++ b/tests/test_ext_marshmallow.py
@@ -51,7 +51,8 @@ class TestDefinitionHelper:
             openapi_version="2.0",
             plugins=(MarshmallowPlugin(schema_name_resolver=resolver),),
         )
-        assert {} == get_schemas(spec)
+        with pytest.raises(KeyError):
+            get_schemas(spec)
 
         spec.components.schema("analysis", schema=schema)
         spec.path(
@@ -84,7 +85,8 @@ class TestDefinitionHelper:
             openapi_version="2.0",
             plugins=(MarshmallowPlugin(schema_name_resolver=resolver),),
         )
-        assert {} == get_schemas(spec)
+        with pytest.raises(KeyError):
+            get_schemas(spec)
 
         spec.components.schema("analysis", schema=schema)
         spec.path(
@@ -115,7 +117,8 @@ class TestDefinitionHelper:
             openapi_version="2.0",
             plugins=(MarshmallowPlugin(schema_name_resolver=resolver),),
         )
-        assert {} == get_schemas(spec)
+        with pytest.raises(KeyError):
+            get_schemas(spec)
 
         with pytest.raises(
             APISpecError, match="Name resolver returned None for schema"
Repository: marshmallow-code/apispec
Pull request #439 (2019-04-29 08:44:03)

Ensure make_schema_key returns a unique key on unhashable iterables
https://github.com/marshmallow-code/apispec/pull/416 reworked.


Patch:
diff --git a/AUTHORS.rst b/AUTHORS.rst
index f5c38c0..2c62f64 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -56,3 +56,4 @@ Contributors (chronological)
 - David Stapleton `@dstape <https://github.com/DStape>`_
 - Szabolcs Blága `@blagasz <https://github.com/blagasz>`_
 - Andrew Johnson `@andrjohn <https://github.com/andrjohn>`_
+- Dave `@zedrdave <https://github.com/zedrdave>`_
diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py
index 8ae05b5..fb80e5a 100644
--- a/src/apispec/ext/marshmallow/common.py
+++ b/src/apispec/ext/marshmallow/common.py
@@ -113,9 +113,11 @@ def make_schema_key(schema):
     for modifier in MODIFIERS:
         attribute = getattr(schema, modifier)
         try:
+            # Hashable (string, tuple)
             hash(attribute)
         except TypeError:
-            attribute = tuple(attribute)
+            # Unhashable iterable (list, set)
+            attribute = frozenset(attribute)
         modifiers.append(attribute)
     return SchemaKey(schema.__class__, *modifiers)
 


Test patch:
diff --git a/tests/test_ext_marshmallow_common.py b/tests/test_ext_marshmallow_common.py
index 8551d2f..c124385 100644
--- a/tests/test_ext_marshmallow_common.py
+++ b/tests/test_ext_marshmallow_common.py
@@ -19,6 +19,13 @@ class TestMakeSchemaKey:
     def test_same_schemas_instances_equal(self):
         assert make_schema_key(PetSchema()) == make_schema_key(PetSchema())
 
+    @pytest.mark.parametrize("structure", (list, set))
+    def test_same_schemas_instances_unhashable_modifiers_equal(self, structure):
+        modifier = [str(i) for i in range(1000)]
+        assert make_schema_key(
+            PetSchema(load_only=structure(modifier))
+        ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1])))
+
     def test_different_schemas_not_equal(self):
         assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema())
Repository: marshmallow-code/apispec
Pull request #443 (2019-05-01 20:48:33)

Fix MarshmallowPlugin.resolve_schema for OAS3 content without schema
https://swagger.io/specification/#mediaTypeObject

`schema` is not required, so there can be content without schema. This PR fixes this use case (and reworks the loop using `itervalues`).


Patch:
diff --git a/src/apispec/ext/marshmallow/__init__.py b/src/apispec/ext/marshmallow/__init__.py
index d96537a..230b674 100644
--- a/src/apispec/ext/marshmallow/__init__.py
+++ b/src/apispec/ext/marshmallow/__init__.py
@@ -36,6 +36,7 @@ from __future__ import absolute_import
 import warnings
 
 from apispec import BasePlugin
+from apispec.compat import itervalues
 from .common import resolve_schema_instance, make_schema_key
 from .openapi import OpenAPIConverter
 
@@ -123,11 +124,11 @@ class MarshmallowPlugin(BasePlugin):
         # OAS 3 component except header
         if self.openapi_version.major >= 3:
             if "content" in data:
-                for content_type in data["content"]:
-                    schema = data["content"][content_type]["schema"]
-                    data["content"][content_type][
-                        "schema"
-                    ] = self.openapi.resolve_schema_dict(schema)
+                for content in itervalues(data["content"]):
+                    if "schema" in content:
+                        content["schema"] = self.openapi.resolve_schema_dict(
+                            content["schema"]
+                        )
 
     def map_to_openapi_type(self, *args):
         """Decorator to set mapping for custom fields.


Test patch:
diff --git a/tests/test_ext_marshmallow.py b/tests/test_ext_marshmallow.py
index c1f2d0e..bac008e 100644
--- a/tests/test_ext_marshmallow.py
+++ b/tests/test_ext_marshmallow.py
@@ -245,6 +245,13 @@ class TestComponentResponseHelper:
         assert resolved_schema["properties"]["name"]["type"] == "string"
         assert resolved_schema["properties"]["password"]["type"] == "string"
 
+    @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True)
+    def test_content_without_schema(self, spec):
+        resp = {"content": {"application/json": {"example": {"name": "Example"}}}}
+        spec.components.response("GetPetOk", resp)
+        response = get_responses(spec)["GetPetOk"]
+        assert response == resp
+
 
 class TestCustomField:
     def test_can_use_custom_field_decorator(self, spec_fixture):
Repository: marshmallow-code/apispec
Pull request #596 (2020-08-28 14:05:20)

Ignore field metadata with non-string keys
Rebase / squash of #585.

(I couldn't find a way to push in PR branch.)

Closes #585.


Patch:
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 309c191..e10eb08 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -64,3 +64,4 @@ Contributors (chronological)
 - Fedor Fominykh `@fedorfo <https://github.com/fedorfo>`_
 - Colin Bounouar `@Colin-b <https://github.com/Colin-b>`_
 - David Bishop `@teancom <https://github.com/teancom>`_
+- Andrea Ghensi `@sanzoghenzo <https://github.com/sanzoghenzo>`_
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 8130ef0..07a7255 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -397,6 +397,7 @@ class FieldConverterMixin:
         metadata = {
             key.replace("_", "-") if key.startswith("x_") else key: value
             for key, value in field.metadata.items()
+            if isinstance(key, str)
         }
 
         # Avoid validation error with "Additional properties not allowed"


Test patch:
diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py
index 701da30..274f0d9 100644
--- a/tests/test_ext_marshmallow_field.py
+++ b/tests/test_ext_marshmallow_field.py
@@ -293,3 +293,13 @@ def test_custom_properties_for_custom_fields(spec_fixture):
     assert properties["x-customString"] == (
         spec_fixture.openapi.openapi_version == "2.0"
     )
+
+
+def test_field2property_with_non_string_metadata_keys(spec_fixture):
+    class _DesertSentinel:
+        pass
+
+    field = fields.Boolean(description="A description")
+    field.metadata[_DesertSentinel()] = "to be ignored"
+    result = spec_fixture.openapi.field2property(field)
+    assert result == {"description": "A description", "type": "boolean"}
Repository: marshmallow-code/apispec
Pull request #650 (2021-03-25 22:43:21)

Resolve header references in responses


Patch:
diff --git a/src/apispec/core.py b/src/apispec/core.py
index 13861ef..c857f2a 100644
--- a/src/apispec/core.py
+++ b/src/apispec/core.py
@@ -407,5 +407,8 @@ class APISpec:
                         if self.openapi_version.major < 3 and code != "default":
                             warnings.warn("Non-integer code not allowed in OpenAPI < 3")
                     self._resolve_schema(response)
-                    responses[str(code)] = self.get_ref("response", response)
+                    response = self.get_ref("response", response)
+                    for name, header in response.get("headers", {}).items():
+                        response["headers"][name] = self.get_ref("header", header)
+                    responses[str(code)] = response
                 operation["responses"] = responses


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index 66b9b8c..0ecca86 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -677,6 +677,15 @@ class TestPath:
             "application/json"
         ]["schema"] == build_ref(spec, "schema", "PetSchema")
 
+    # "headers" components section only exists in OAS 3
+    @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True)
+    def test_path_resolve_response_header(self, spec):
+        response = {"headers": {"header_1": "Header_1"}}
+        spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}})
+        resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"]
+        header_1 = resp["headers"]["header_1"]
+        assert header_1 == build_ref(spec, "header", "Header_1")
+
 
 class TestPlugins:
     @staticmethod
Repository: marshmallow-code/apispec
Pull request #769 (2022-05-11 22:58:56)

Set default yaml.dump sort_keys to False to respect dictionary order
Implemented fix proposed by @lafrech https://github.com/marshmallow-code/apispec/issues/768#issuecomment-1123292470


Patch:
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 074d447..39eed04 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -74,3 +74,4 @@ Contributors (chronological)
 - François Magimel `<https://github.com/Linkid>`_
 - Stefan van der Walt `<https://github.com/stefanv>`_
 - `<https://github.com/kasium>`_
+- Edwin Erdmanis `@vorticity <https://github.com/vorticity>`_
diff --git a/src/apispec/yaml_utils.py b/src/apispec/yaml_utils.py
index 8a60e2b..87dce92 100644
--- a/src/apispec/yaml_utils.py
+++ b/src/apispec/yaml_utils.py
@@ -9,8 +9,11 @@ from apispec.utils import trim_docstring, dedent
 
 
 def dict_to_yaml(dic: dict, yaml_dump_kwargs: typing.Any | None = None) -> str:
-    if yaml_dump_kwargs is None:
-        yaml_dump_kwargs = {}
+    """Serializes a dictionary to YAML."""
+    yaml_dump_kwargs = yaml_dump_kwargs or {}
+
+    # By default, don't sort alphabetically to respect schema field ordering
+    yaml_dump_kwargs.setdefault("sort_keys", False)
     return yaml.dump(dic, **yaml_dump_kwargs)
 
 


Test patch:
diff --git a/tests/test_yaml_utils.py b/tests/test_yaml_utils.py
index b538c01..39351fe 100644
--- a/tests/test_yaml_utils.py
+++ b/tests/test_yaml_utils.py
@@ -31,3 +31,16 @@ def test_load_operations_from_docstring_empty_docstring(docstring):
 def test_dict_to_yaml_unicode():
     assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n'
     assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n"
+
+
+def test_dict_to_yaml_keys_are_not_sorted_by_default():
+    assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n"
+
+
+def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs():
+    assert (
+        yaml_utils.dict_to_yaml(
+            {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True}
+        )
+        == "derp: 2\nherp: 1\n"
+    )
Repository: marshmallow-code/apispec
Pull request #825 (2023-03-03 10:23:02)

field2range: serialize min/max values
Values must be serialized to be published in the documentation.


Patch:
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 268be4a..051b26f 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -320,7 +320,12 @@ class FieldConverterMixin:
             if set(make_type_list(ret.get("type"))) & {"number", "integer"}
             else ("x-minimum", "x-maximum")
         )
-        return make_min_max_attributes(validators, min_attr, max_attr)
+
+        # Serialize min/max values with the field to which the validator is applied
+        return {
+            k: field._serialize(v, None, None)
+            for k, v in make_min_max_attributes(validators, min_attr, max_attr).items()
+        }
 
     def field2length(
         self, field: marshmallow.fields.Field, **kwargs: typing.Any


Test patch:
diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py
index 41143dd..0fb04b6 100644
--- a/tests/test_ext_marshmallow_field.py
+++ b/tests/test_ext_marshmallow_field.py
@@ -238,6 +238,19 @@ def test_field_with_range_type_list_without_number(spec_fixture):
     assert res["type"] == ["string", "null"]
 
 
+def test_field_with_range_datetime_type(spec_fixture):
+    field = fields.DateTime(
+        validate=validate.Range(
+            min=dt.datetime(1900, 1, 1),
+            max=dt.datetime(2000, 1, 1),
+        )
+    )
+    res = spec_fixture.openapi.field2property(field)
+    assert res["x-minimum"] == "1900-01-01T00:00:00"
+    assert res["x-maximum"] == "2000-01-01T00:00:00"
+    assert isinstance(res["type"], str)
+
+
 def test_field_with_str_regex(spec_fixture):
     regex_str = "^[a-zA-Z0-9]$"
     field = fields.Str(validate=validate.Regexp(regex_str))
diff --git a/tests/test_ext_marshmallow_openapi.py b/tests/test_ext_marshmallow_openapi.py
index fc27626..2617329 100644
--- a/tests/test_ext_marshmallow_openapi.py
+++ b/tests/test_ext_marshmallow_openapi.py
@@ -666,7 +666,7 @@ class TestFieldValidation:
             ("custom_field_length", {"minLength": 1, "maxLength": 10}),
             ("multiple_lengths", {"minLength": 3, "maxLength": 7}),
             ("equal_length", {"minLength": 5, "maxLength": 5}),
-            ("date_range", {"x-minimum": datetime(1900, 1, 1)}),
+            ("date_range", {"x-minimum": "1900-01-01T00:00:00"}),
         ],
     )
     def test_properties(self, field, properties, spec):
Repository: marshmallow-code/apispec
Pull request #892 (2024-03-14 13:58:54)

Add IP fields to DEFAULT_FIELD_MAPPING
This relates to https://github.com/marshmallow-code/flask-smorest/issues/623 where Swagger was not obeying `required=True` for the `IPv4` field. This adds the different IP fields to the DEFAULT_FIELD_MAPPING where the type is string the format is the IP address format.


Patch:
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 77d7c52..0ab09da 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -81,3 +81,4 @@ Contributors (chronological)
 - Sebastien Lovergne `@TheBigRoomXXL <https://github.com/TheBigRoomXXL>`_
 - Luna Lovegood `@duchuyvp <https://github.com/duchuyvp>`_
 - Tobias Kolditz `@kolditz-senec <https://github.com/kolditz-senec>`_
+- Christian Proud `@cjproud <https://github.com/cjproud>`_
\ No newline at end of file
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 98bab02..c3b1065 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -38,6 +38,9 @@ DEFAULT_FIELD_MAPPING: dict[type, tuple[str | None, str | None]] = {
     marshmallow.fields.Field: (None, None),
     marshmallow.fields.Raw: (None, None),
     marshmallow.fields.List: ("array", None),
+    marshmallow.fields.IP: ("string", "ip"),
+    marshmallow.fields.IPv4: ("string", "ipv4"),
+    marshmallow.fields.IPv6: ("string", "ipv6"),
 }
 
 


Test patch:
diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py
index b4f7362..1f85fc3 100644
--- a/tests/test_ext_marshmallow_field.py
+++ b/tests/test_ext_marshmallow_field.py
@@ -32,6 +32,9 @@ def test_field2choices_preserving_order(openapi):
         (fields.TimeDelta, "integer"),
         (fields.Email, "string"),
         (fields.URL, "string"),
+        (fields.IP, "string"),
+        (fields.IPv4, "string"),
+        (fields.IPv6, "string"),
         # Custom fields inherit types from their parents
         (CustomStringField, "string"),
         (CustomIntegerField, "integer"),
@@ -66,6 +69,9 @@ def test_formatted_field_translates_to_array(ListClass, spec_fixture):
         (fields.Date, "date"),
         (fields.Email, "email"),
         (fields.URL, "url"),
+        (fields.IP, "ip"),
+        (fields.IPv4, "ipv4"),
+        (fields.IPv6, "ipv6"),
     ],
 )
 def test_field2property_formats(FieldClass, expected_format, spec_fixture):
Repository: marshmallow-code/apispec
Pull request #957 (2024-11-23 07:16:17)

Fix nullable nested schemas with metadata in 3.0
Fixes https://github.com/marshmallow-code/apispec/issues/955

Applied the same `allOf` logic seen used in 3.1 (See https://github.com/marshmallow-code/apispec/pull/904)


Patch:
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 63fbe96..1a40b9a 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -306,6 +306,11 @@ class FieldConverterMixin:
                         {"type": "object", "nullable": True},
                         {"$ref": ret.pop("$ref")},
                     ]
+                elif "allOf" in ret:
+                    attributes["anyOf"] = [
+                        *ret.pop("allOf"),
+                        {"type": "object", "nullable": True},
+                    ]
                 else:
                     attributes["nullable"] = True
             else:


Test patch:
diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py
index 5e5250b..eca4a10 100644
--- a/tests/test_ext_marshmallow_field.py
+++ b/tests/test_ext_marshmallow_field.py
@@ -222,6 +222,42 @@ def test_nested_nullable(spec_fixture):
         }
 
 
+@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True)
+def test_nested_nullable_with_metadata(spec_fixture):
+    # Regression test for https://github.com/marshmallow-code/apispec/issues/955
+    class Child(Schema):
+        name = fields.Str()
+
+    field = fields.Nested(
+        Child,
+        allow_none=True,
+        metadata={"description": "foo"},
+    )
+    res = spec_fixture.openapi.field2property(field)
+    version = spec_fixture.openapi.openapi_version
+    if version.major < 3:
+        assert res == {
+            "allOf": [
+                {"$ref": "#/definitions/Child"},
+            ],
+            "x-nullable": True,
+            "description": "foo",
+        }
+    elif version.major == 3 and version.minor < 1:
+        assert res == {
+            "anyOf": [
+                {"$ref": "#/components/schemas/Child"},
+                {"type": "object", "nullable": True},
+            ],
+            "description": "foo",
+        }
+    else:
+        assert res == {
+            "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}],
+            "description": "foo",
+        }
+
+
 @pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True)
 def test_nullable_pluck(spec_fixture):
     class Example(Schema):
Repository: marshmallow-code/apispec
Pull request #976 (2025-05-10 16:11:15)

Avoid overwriting `additionalProperties` with the default `{}`
A few versions ago, the output of `Dict()` omitted `additionalProperties` entirely and I used `Dict(metadata={"additionalProperties": True})` as a workaround. Now the output of `additionalProperties: {}` will breakdown our internal tools.
Although `additionalProperties: {}` is equivalent to `additionalProperties: true`, I think it's better not to overwrite the manually set value.


Patch:
diff --git a/AUTHORS.rst b/AUTHORS.rst
index a087a27..22ce7b3 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -86,3 +86,4 @@ Contributors (chronological)
 - Theron Luhn `@luhn <https://github.com/luhn>`_
 - Robert Shepley `@ShepleySound <https://github.com/ShepleySound>`_
 - Robin `@allrob23 <https://github.com/allrob23>`_
+- Xingang Zhang `@0x0400 <https://github.com/0x0400>`_
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 463e135..5273290 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,12 @@ Changelog
 (unreleased)
 ************
 
+Bug fixes:
+
+- ``MarshmallowPlugin`` doesn't override ``additionalProperties`` explicitly
+  passed to ``fields.Dict`` (:pr:`976`).
+  Thanks :user:`0x0400` for the PR.
+
 - Perf improvement to ``filter_excluded_fields`` (:issue:`972`).
   Thanks :user:`allrob23` for the PR.
 
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 4ae544b..bb43a6a 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -523,7 +523,7 @@ class FieldConverterMixin:
             value_field = field.value_field
             if value_field:
                 ret["additionalProperties"] = self.field2property(value_field)
-            else:
+            elif "additionalProperties" not in kwargs.get("ret", {}):
                 ret["additionalProperties"] = {}
         return ret
 


Test patch:
diff --git a/tests/test_ext_marshmallow.py b/tests/test_ext_marshmallow.py
index 0b863f4..b32d23c 100644
--- a/tests/test_ext_marshmallow.py
+++ b/tests/test_ext_marshmallow.py
@@ -1296,6 +1296,14 @@ class TestDictValues:
         result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"]
         assert result == {"type": "object", "additionalProperties": {}}
 
+    def test_dict_with_empty_values_field_and_metadata(self, spec):
+        class SchemaWithDict(Schema):
+            dict_field = Dict(metadata={"additionalProperties": True})
+
+        spec.components.schema("SchemaWithDict", schema=SchemaWithDict)
+        result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"]
+        assert result == {"type": "object", "additionalProperties": True}
+
     def test_dict_with_nested(self, spec):
         class SchemaWithDict(Schema):
             dict_field = Dict(values=Nested(PetSchema))