@@ -227,7 +227,7 @@ def parse_form(
227
227
228
228
assert properties , f"{ form .__name__ } 's properties cannot be empty."
229
229
230
- title = schema .get ("title" )
230
+ title = schema .get ("title" ) or form . __name__
231
231
components_schemas [title ] = Schema (** schema )
232
232
encoding = {}
233
233
for k , v in properties .items ():
@@ -269,7 +269,7 @@ def parse_body(
269
269
schema = get_model_schema (body )
270
270
components_schemas = dict ()
271
271
272
- title = schema .get ("title" )
272
+ title = schema .get ("title" ) or body . __name__
273
273
components_schemas [title ] = Schema (** schema )
274
274
if extra_body :
275
275
content = {
@@ -320,17 +320,18 @@ def get_responses(
320
320
)})
321
321
322
322
model_config = response .Config
323
- if hasattr (model_config , "openapi_extra" ):
323
+ openapi_extra : dict = getattr (model_config , "openapi_extra" , None ) # type: ignore
324
+ if openapi_extra :
324
325
# Add additional information from model_config to the response
325
- _responses [key ].description = model_config . openapi_extra .get ("description" )
326
- _responses [key ].headers = model_config . openapi_extra .get ("headers" )
327
- _responses [key ].links = model_config . openapi_extra .get ("links" )
326
+ _responses [key ].description = openapi_extra .get ("description" ) # type: ignore
327
+ _responses [key ].headers = openapi_extra .get ("headers" )
328
+ _responses [key ].links = openapi_extra .get ("links" )
328
329
_content = _responses [key ].content
329
- _content ["application/json" ].example = model_config . openapi_extra .get ("example" ) # type: ignore
330
- _content ["application/json" ].examples = model_config . openapi_extra .get ("examples" ) # type: ignore
331
- _content ["application/json" ].encoding = model_config . openapi_extra .get ("encoding" ) # type: ignore
332
- if model_config . openapi_extra .get ("content" ):
333
- _responses [key ].content .update (model_config . openapi_extra .get ("content" )) # type: ignore
330
+ _content ["application/json" ].example = openapi_extra .get ("example" ) # type: ignore
331
+ _content ["application/json" ].examples = openapi_extra .get ("examples" ) # type: ignore
332
+ _content ["application/json" ].encoding = openapi_extra .get ("encoding" ) # type: ignore
333
+ if openapi_extra .get ("content" ):
334
+ _responses [key ].content .update (openapi_extra .get ("content" )) # type: ignore
334
335
335
336
_schemas [response .__name__ ] = Schema (** schema )
336
337
definitions = schema .get ("definitions" )
@@ -468,12 +469,13 @@ def parse_parameters(
468
469
"content" : _content ,
469
470
})
470
471
model_config = form .Config
471
- if hasattr (model_config , "openapi_extra" ):
472
- request_body .description = model_config .openapi_extra .get ("description" )
473
- request_body .content ["multipart/form-data" ].example = model_config .openapi_extra .get ("example" )
474
- request_body .content ["multipart/form-data" ].examples = model_config .openapi_extra .get ("examples" )
475
- if model_config .openapi_extra .get ("encoding" ):
476
- request_body .content ["multipart/form-data" ].encoding = model_config .openapi_extra .get ("encoding" )
472
+ openapi_extra : dict = getattr (model_config , "openapi_extra" , None ) # type: ignore
473
+ if openapi_extra :
474
+ request_body .description = openapi_extra .get ("description" )
475
+ request_body .content ["multipart/form-data" ].example = openapi_extra .get ("example" )
476
+ request_body .content ["multipart/form-data" ].examples = openapi_extra .get ("examples" )
477
+ if openapi_extra .get ("encoding" ):
478
+ request_body .content ["multipart/form-data" ].encoding = openapi_extra .get ("encoding" )
477
479
operation .requestBody = request_body
478
480
479
481
if body :
@@ -488,11 +490,12 @@ def parse_parameters(
488
490
else :
489
491
request_body = RequestBody (content = _content )
490
492
model_config = body .Config
491
- if hasattr (model_config , "openapi_extra" ):
492
- request_body .description = model_config .openapi_extra .get ("description" )
493
- request_body .content ["application/json" ].example = model_config .openapi_extra .get ("example" )
494
- request_body .content ["application/json" ].examples = model_config .openapi_extra .get ("examples" )
495
- request_body .content ["application/json" ].encoding = model_config .openapi_extra .get ("encoding" )
493
+ openapi_extra : dict = getattr (model_config , "openapi_extra" , None ) # type: ignore
494
+ if openapi_extra :
495
+ request_body .description = openapi_extra .get ("description" )
496
+ request_body .content ["application/json" ].example = openapi_extra .get ("example" )
497
+ request_body .content ["application/json" ].examples = openapi_extra .get ("examples" )
498
+ request_body .content ["application/json" ].encoding = openapi_extra .get ("encoding" )
496
499
operation .requestBody = request_body
497
500
498
501
# Set the parsed parameters in the operation object
0 commit comments