Repository: s-knibbs/dataclasses-jsonschema (python)

Issue:
Include enum name information in the JSON schema
To improve the generation of code from the JSON schema, an extension field ('x-enum-name') could be added to any fields using an enum.

Pull request description:
Fix #21: Include enum name information in schema

Patch:
diff --git a/dataclasses_jsonschema/__init__.py b/dataclasses_jsonschema/__init__.py
index 81282e9..f52c935 100644
--- a/dataclasses_jsonschema/__init__.py
+++ b/dataclasses_jsonschema/__init__.py
@@ -264,6 +264,7 @@ class JsonSchemaMixin:
                     else:
                         field_schema.update(cls._field_encoders[member_types.pop()].json_schema)
                 field_schema['enum'] = values
+                field_schema['x-enum-name'] = field_type_name
             elif field_type_name in ('Dict', 'Mapping'):
                 field_schema = {'type': 'object'}
                 if field_type.__args__[1] is not Any:


Test patch:
diff --git a/tests/test_all.py b/tests/test_all.py
index e513cc0..b1d32ab 100644
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -16,7 +16,11 @@ FOO_SCHEMA = {
         'a': {'format': 'date-time', 'type': 'string'},
         'b': {'items': {'$ref': '#/definitions/Point'}, 'type': 'array'},
         'c': {'additionalProperties': {'type': 'integer'}, 'type': 'object'},
-        'd': {'type': 'string', 'enum': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']},
+        'd': {
+            'type': 'string',
+            'enum': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
+            'x-enum-name': 'Weekday'
+        },
         'f': {'type': 'array', 'minItems': 2, 'maxItems': 2, 'items': [{'type': 'string'}, {'type': 'integer'}]},
         'g': {'type': 'array', 'items': {'type': 'string'}},
         'e': {'type': 'string', 'minLength': 5, 'maxLength': 8},