This repository was archived by the owner on Mar 18, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -39,17 +39,21 @@ def encode_schema_to_corejson(schema):
39
39
'description' : schema .description
40
40
}
41
41
if isinstance (schema , coreschema .Enum ):
42
- retval ['extra ' ] = { 'enum' : schema .enum }
42
+ retval ['enum ' ] = schema .enum
43
43
return retval
44
44
45
45
46
46
def decode_schema_from_corejson (data ):
47
47
type_id = _get_string (data , '_type' )
48
48
title = _get_string (data , 'title' )
49
49
description = _get_string (data , 'description' )
50
- extra = _get_dict (data , 'extra' )
50
+
51
+ kwargs = {}
52
+ if type_id == 'enum' :
53
+ kwargs ['enum' ] = _get_list (data , 'enum' )
54
+
51
55
schema_cls = TYPE_ID_TO_SCHEMA_CLASS .get (type_id , coreschema .Anything )
52
- return schema_cls (title = title , description = description , ** extra )
56
+ return schema_cls (title = title , description = description , ** kwargs )
53
57
54
58
55
59
# Robust dictionary lookups, that always return an item of the correct
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ def test_document_to_primitive(doc):
63
63
'_type' : 'enum' ,
64
64
'title' : '' ,
65
65
'description' : '' ,
66
- 'extra' : { ' enum' : ['a' , 'b' , 'c' ]} ,
66
+ 'enum' : ['a' , 'b' , 'c' ],
67
67
},
68
68
},
69
69
]},
@@ -101,7 +101,7 @@ def test_primitive_to_document(doc):
101
101
'_type' : 'enum' ,
102
102
'title' : '' ,
103
103
'description' : '' ,
104
- 'extra' : { ' enum' : ['a' , 'b' , 'c' ]} ,
104
+ 'enum' : ['a' , 'b' , 'c' ],
105
105
},
106
106
},
107
107
],
You can’t perform that action at this time.
0 commit comments