Repository: marshmallow-code/apispec

Issue:
Support with marshmallow.fields.Enum
[marshmallow.fields.Enum](https://marshmallow.readthedocs.io/en/stable/marshmallow.fields.html#marshmallow.fields.Enum) can be used now.

Could apispec supports with it, Thanks!

Discussion:

Patch:
diff --git a/setup.py b/setup.py
index be79866..089f23e 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
 INSTALL_REQUIRES = "packaging>=21.3"
 
 EXTRAS_REQUIRE = {
-    "marshmallow": ["marshmallow>=3.13.0"],
+    "marshmallow": ["marshmallow>=3.18.0"],
     "yaml": ["PyYAML>=3.10"],
     "validation": ["prance[osv]>=0.11", "openapi_spec_validator<0.5"],
     "lint": [
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 4036e74..2a5beaa 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -105,6 +105,7 @@ class FieldConverterMixin:
             self.field2length,
             self.field2pattern,
             self.metadata2properties,
+            self.enum2properties,
             self.nested2properties,
             self.pluck2properties,
             self.list2properties,
@@ -501,6 +502,18 @@ class FieldConverterMixin:
             ret["x-unit"] = field.precision
         return ret
 
+    def enum2properties(self, field, **kwargs: typing.Any) -> dict:
+        """Return a dictionary of properties from :class:`Enum <marshmallow.fields.Enum` fields.
+
+        :param Field field: A marshmallow field.
+        :rtype: dict
+        """
+        ret = {}
+        if isinstance(field, marshmallow.fields.Enum):
+            ret = self.field2property(field.field)
+            ret["enum"] = field.choices_text
+        return ret
+
 
 def make_type_list(types):
     """Return a list of types from a type attribute


Test patch:
diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py
index 80a0a69..aab4304 100644
--- a/tests/test_ext_marshmallow_field.py
+++ b/tests/test_ext_marshmallow_field.py
@@ -1,5 +1,6 @@
 import datetime as dt
 import re
+from enum import Enum
 
 import pytest
 from marshmallow import fields, validate
@@ -263,6 +264,32 @@ def test_field_with_multiple_patterns(recwarn, spec_fixture):
     assert ret["pattern"] == "winner"
 
 
+def test_enum_symbol_field(spec_fixture):
+    class MyEnum(Enum):
+        one = 1
+        two = 2
+
+    field = fields.Enum(MyEnum)
+    ret = spec_fixture.openapi.field2property(field)
+    assert ret["type"] == "string"
+    assert ret["enum"] == "one, two"
+
+
+@pytest.mark.parametrize("by_value", [fields.Integer, True])
+def test_enum_value_field(spec_fixture, by_value):
+    class MyEnum(Enum):
+        one = 1
+        two = 2
+
+    field = fields.Enum(MyEnum, by_value=by_value)
+    ret = spec_fixture.openapi.field2property(field)
+    if by_value is True:
+        assert "type" not in ret
+    else:
+        assert ret["type"] == "integer"
+    assert ret["enum"] == "1, 2"
+
+
 def test_field2property_nested_spec_metadatas(spec_fixture):
     spec_fixture.spec.components.schema("Category", schema=CategorySchema)
     category = fields.Nested(