@@ -141,28 +141,22 @@ def convert_schema(schema, spec: APISpec):
141
141
if not schema :
142
142
return schema
143
143
144
- # Call callables
145
- if callable (schema ):
146
- working_schema = schema ()
147
- else :
148
- working_schema = schema
149
-
150
144
# Expand/convert actual schema data
151
- if isinstance (working_schema , BaseSchema ):
152
- return working_schema
153
- elif isinstance (working_schema , Mapping ):
154
- return map2properties (working_schema , spec )
155
- elif isinstance (working_schema , Field ):
156
- return field2property (working_schema , spec )
145
+ if isinstance (schema , BaseSchema ):
146
+ return schema
147
+ elif isinstance (schema , Mapping ):
148
+ return map2properties (schema , spec )
149
+ elif isinstance (schema , Field ):
150
+ return field2property (schema , spec )
157
151
else :
158
152
raise TypeError (
159
- f"Unsupported schema type { working_schema } . Ensure schema is a Schema class, or dictionary of Field objects"
153
+ f"Unsupported schema type { schema } . Ensure schema is a Schema class, or dictionary of Field objects"
160
154
)
161
155
162
156
163
157
def map2properties (schema , spec : APISpec ):
164
158
"""
165
- Convert any dictionary-like map of Marshmallow fields into a dictionary describing it's JSON schema
159
+ Recursively convert any dictionary-like map of Marshmallow fields into a dictionary describing it's JSON schema
166
160
"""
167
161
marshmallow_plugin = next (
168
162
plugin for plugin in spec .plugins if isinstance (plugin , MarshmallowPlugin )
@@ -195,12 +189,10 @@ def field2property(field, spec: APISpec):
195
189
196
190
def schema2json (schema , spec : APISpec ):
197
191
"""
198
- Convert any Marshmallow schema, field, or dictionary of fields stright to a JSON schema
192
+ Convert any Marshmallow schema stright to a JSON schema.
199
193
This should not be used when generating APISpec documentation, otherwise schemas wont
200
194
be listed in the "schemas" list. This is used, for example, in the Thing Description.
201
195
"""
202
- if not isinstance (schema , BaseSchema ):
203
- schema = convert_schema (schema , spec )
204
196
205
197
if isinstance (schema , BaseSchema ):
206
198
marshmallow_plugin = next (
0 commit comments