77import warnings
88from abc import ABC
99from functools import wraps
10- from typing import Callable , List , Optional , Dict , Type , Any , Tuple
10+ from typing import Callable , List , Optional , Dict , Type , Any , Tuple , Union
1111
1212from flask .scaffold import Scaffold
1313from flask .wrappers import Response
@@ -48,7 +48,7 @@ def _do_decorator(
4848 operation_id : Optional [str ] = None ,
4949 extra_form : Optional [ExtraRequestBody ] = None ,
5050 extra_body : Optional [ExtraRequestBody ] = None ,
51- responses : Optional [Dict [str , Optional [Type [BaseModel ]]]] = None ,
51+ responses : Optional [Dict [str , Union [Type [BaseModel ], Dict [ Any , Any ], None ]]] = None ,
5252 extra_responses : Optional [Dict [str , dict ]] = None ,
5353 deprecated : Optional [bool ] = None ,
5454 security : Optional [List [Dict [str , List [Any ]]]] = None ,
@@ -146,7 +146,7 @@ def get(
146146 operation_id : Optional [str ] = None ,
147147 extra_form : Optional [ExtraRequestBody ] = None ,
148148 extra_body : Optional [ExtraRequestBody ] = None ,
149- responses : Optional [Dict [str , Optional [Type [BaseModel ]]]] = None ,
149+ responses : Optional [Dict [str , Union [Type [BaseModel ], Dict [ Any , Any ], None ]]] = None ,
150150 extra_responses : Optional [Dict [str , dict ]] = None ,
151151 deprecated : Optional [bool ] = None ,
152152 security : Optional [List [Dict [str , List [Any ]]]] = None ,
@@ -168,7 +168,7 @@ def get(
168168 operation_id: Unique string used to identify the operation.
169169 extra_form: Extra information describing the request body(application/form).
170170 extra_body: Extra information describing the request body(application/json).
171- responses: response's model must be pydantic BaseModel.
171+ responses: API responses, should be BaseModel, dict or None .
172172 extra_responses: Extra information for responses.
173173 deprecated: Declares this operation to be deprecated.
174174 security: A declaration of which security mechanisms can be used for this operation.
@@ -185,6 +185,10 @@ def get(
185185 warnings .warn (
186186 """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""" ,
187187 DeprecationWarning )
188+ if extra_responses is not None :
189+ warnings .warn (
190+ """`extra_responses` will be deprecated in v3.x, please use `responses` instead.""" ,
191+ DeprecationWarning )
188192
189193 def decorator (func ) -> Callable :
190194 header , cookie , path , query , form , body = \
@@ -227,7 +231,7 @@ def post(
227231 operation_id : Optional [str ] = None ,
228232 extra_form : Optional [ExtraRequestBody ] = None ,
229233 extra_body : Optional [ExtraRequestBody ] = None ,
230- responses : Optional [Dict [str , Optional [Type [BaseModel ]]]] = None ,
234+ responses : Optional [Dict [str , Union [Type [BaseModel ], Dict [ Any , Any ], None ]]] = None ,
231235 extra_responses : Optional [Dict [str , dict ]] = None ,
232236 deprecated : Optional [bool ] = None ,
233237 security : Optional [List [Dict [str , List [Any ]]]] = None ,
@@ -249,7 +253,7 @@ def post(
249253 operation_id: Unique string used to identify the operation.
250254 extra_form: Extra information describing the request body(application/form).
251255 extra_body: Extra information describing the request body(application/json).
252- responses: response's model must be pydantic BaseModel.
256+ responses: API responses, should be BaseModel, dict or None .
253257 extra_responses: Extra information for responses.
254258 deprecated: Declares this operation to be deprecated.
255259 security: A declaration of which security mechanisms can be used for this operation.
@@ -265,6 +269,10 @@ def post(
265269 warnings .warn (
266270 """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""" ,
267271 DeprecationWarning )
272+ if extra_responses is not None :
273+ warnings .warn (
274+ """`extra_responses` will be deprecated in v3.x, please use `responses` instead.""" ,
275+ DeprecationWarning )
268276
269277 def decorator (func ) -> Callable :
270278 header , cookie , path , query , form , body = \
@@ -307,7 +315,7 @@ def put(
307315 operation_id : Optional [str ] = None ,
308316 extra_form : Optional [ExtraRequestBody ] = None ,
309317 extra_body : Optional [ExtraRequestBody ] = None ,
310- responses : Optional [Dict [str , Optional [Type [BaseModel ]]]] = None ,
318+ responses : Optional [Dict [str , Union [Type [BaseModel ], Dict [ Any , Any ], None ]]] = None ,
311319 extra_responses : Optional [Dict [str , dict ]] = None ,
312320 deprecated : Optional [bool ] = None ,
313321 security : Optional [List [Dict [str , List [Any ]]]] = None ,
@@ -329,7 +337,7 @@ def put(
329337 operation_id: Unique string used to identify the operation.
330338 extra_form: Extra information describing the request body(application/form).
331339 extra_body: Extra information describing the request body(application/json).
332- responses: response's model must be pydantic BaseModel.
340+ responses: API responses, should be BaseModel, dict or None .
333341 extra_responses: Extra information for responses.
334342 deprecated: Declares this operation to be deprecated.
335343 security: A declaration of which security mechanisms can be used for this operation.
@@ -345,6 +353,10 @@ def put(
345353 warnings .warn (
346354 """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""" ,
347355 DeprecationWarning )
356+ if extra_responses is not None :
357+ warnings .warn (
358+ """`extra_responses` will be deprecated in v3.x, please use `responses` instead.""" ,
359+ DeprecationWarning )
348360
349361 def decorator (func ) -> Callable :
350362 header , cookie , path , query , form , body = \
@@ -387,7 +399,7 @@ def delete(
387399 operation_id : Optional [str ] = None ,
388400 extra_form : Optional [ExtraRequestBody ] = None ,
389401 extra_body : Optional [ExtraRequestBody ] = None ,
390- responses : Optional [Dict [str , Optional [Type [BaseModel ]]]] = None ,
402+ responses : Optional [Dict [str , Union [Type [BaseModel ], Dict [ Any , Any ], None ]]] = None ,
391403 extra_responses : Optional [Dict [str , dict ]] = None ,
392404 deprecated : Optional [bool ] = None ,
393405 security : Optional [List [Dict [str , List [Any ]]]] = None ,
@@ -409,7 +421,7 @@ def delete(
409421 operation_id: Unique string used to identify the operation.
410422 extra_form: Extra information describing the request body(application/form).
411423 extra_body: Extra information describing the request body(application/json).
412- responses: response's model must be pydantic BaseModel.
424+ responses: API responses, should be BaseModel, dict or None .
413425 extra_responses: Extra information for responses.
414426 deprecated: Declares this operation to be deprecated.
415427 security: A declaration of which security mechanisms can be used for this operation.
@@ -425,6 +437,10 @@ def delete(
425437 warnings .warn (
426438 """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""" ,
427439 DeprecationWarning )
440+ if extra_responses is not None :
441+ warnings .warn (
442+ """`extra_responses` will be deprecated in v3.x, please use `responses` instead.""" ,
443+ DeprecationWarning )
428444
429445 def decorator (func ) -> Callable :
430446 header , cookie , path , query , form , body = \
@@ -467,7 +483,7 @@ def patch(
467483 operation_id : Optional [str ] = None ,
468484 extra_form : Optional [ExtraRequestBody ] = None ,
469485 extra_body : Optional [ExtraRequestBody ] = None ,
470- responses : Optional [Dict [str , Optional [Type [BaseModel ]]]] = None ,
486+ responses : Optional [Dict [str , Union [Type [BaseModel ], Dict [ Any , Any ], None ]]] = None ,
471487 extra_responses : Optional [Dict [str , dict ]] = None ,
472488 deprecated : Optional [bool ] = None ,
473489 security : Optional [List [Dict [str , List [Any ]]]] = None ,
@@ -489,7 +505,7 @@ def patch(
489505 operation_id: Unique string used to identify the operation.
490506 extra_form: Extra information describing the request body(application/form).
491507 extra_body: Extra information describing the request body(application/json).
492- responses: response's model must be pydantic BaseModel.
508+ responses: API responses, should be BaseModel, dict or None .
493509 extra_responses: Extra information for responses.
494510 deprecated: Declares this operation to be deprecated.
495511 security: A declaration of which security mechanisms can be used for this operation.
@@ -505,6 +521,10 @@ def patch(
505521 warnings .warn (
506522 """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""" ,
507523 DeprecationWarning )
524+ if extra_responses is not None :
525+ warnings .warn (
526+ """`extra_responses` will be deprecated in v3.x, please use `responses` instead.""" ,
527+ DeprecationWarning )
508528
509529 def decorator (func ) -> Callable :
510530 header , cookie , path , query , form , body = \
0 commit comments