Repository: marshmallow-code/apispec

Issue:
exported marshmallow Enum fields should be arrays, not CSV strings
Hi, 

I really love new support for marshmalow Enum fields but... these are not correctly exported into OAS3 :disappointed: .

We get strings:

```json
"status": {
  "type": "string",  
  "enum": "INACTIVE, ACTIVE"
}
```

but we need lists:

```json
"status": {
  "type": "string",
  "enum": [
    "INACTIVE",  "ACTIVE"
  ]
}
```

This breaks ReDoc completelly (fails to load spec and UI), and SwaggerUI partially (loads UI, but errors into console when trying to display some object schema).

Relevant docs:

- [OpenAPI guide - enums](https://swagger.io/docs/specification/data-models/enums/)
- [OpenAPI specification Schema Object - properties](https://swagger.io/specification/#schema-object)
- [JSON Schema Validation](https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.20)

Minimal example:

```py
import enum
import json
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from marshmallow import Schema, fields

spec = APISpec(
    title="Example",
    version="1.0.0",
    openapi_version="3.0.2",
    plugins=[MarshmallowPlugin()],
)

class Statuses(enum.Enum):
    INACTIVE = 0
    ACTIVE = 1

class ItemSchema(Schema):
    id = fields.Int()
    status = fields.Enum(Statuses, allow_none=False)

spec.components.schema("Item", schema=ItemSchema)

print(json.dumps(spec.to_dict(), indent=2))
```

gives us this:

```jsoh
{
  "paths": {},
  "info": {
    "title": "Example",
    "version": "1.0.0"
  },
  "openapi": "3.0.2",
  "components": {
    "schemas": {
      "Item": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": "INACTIVE, ACTIVE"
          }
        }
      }
    }
  }
}
```


Comments:

Patch:
diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py
index 5c9abc5..20bc56f 100644
--- a/src/apispec/ext/marshmallow/field_converter.py
+++ b/src/apispec/ext/marshmallow/field_converter.py
@@ -509,7 +509,11 @@ class FieldConverterMixin:
         ret = {}
         if isinstance(field, marshmallow.fields.Enum):
             ret = self.field2property(field.field)
-            ret["enum"] = field.choices_text
+            if field.by_value is False:
+                choices = (m for m in field.enum.__members__)
+            else:
+                choices = (m.value for m in field.enum)
+            ret["enum"] = [field.field._serialize(v, None, None) for v in choices]
         return ret
 
 


Test patch:
diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py
index dcba184..41143dd 100644
--- a/tests/test_ext_marshmallow_field.py
+++ b/tests/test_ext_marshmallow_field.py
@@ -274,7 +274,7 @@ def test_enum_symbol_field(spec_fixture):
     field = fields.Enum(MyEnum)
     ret = spec_fixture.openapi.field2property(field)
     assert ret["type"] == "string"
-    assert ret["enum"] == "one, two"
+    assert ret["enum"] == ["one", "two"]
 
 
 @pytest.mark.parametrize("by_value", [fields.Integer, True])
@@ -289,7 +289,7 @@ def test_enum_value_field(spec_fixture, by_value):
         assert "type" not in ret
     else:
         assert ret["type"] == "integer"
-    assert ret["enum"] == "1, 2"
+    assert ret["enum"] == [1, 2]
 
 
 def test_field2property_nested_spec_metadatas(spec_fixture):