|
4 | 4 | import functools |
5 | 5 | import inspect |
6 | 6 | import sys |
| 7 | +import warnings |
7 | 8 | from abc import ABC |
8 | 9 | from functools import wraps |
9 | 10 | from typing import Callable, List, Optional, Dict, Type, Any, Tuple |
@@ -31,6 +32,8 @@ def iscoroutinefunction(func: Any) -> bool: |
31 | 32 |
|
32 | 33 | return inspect.iscoroutinefunction(func) |
33 | 34 |
|
| 35 | +warnings.simplefilter("once") |
| 36 | + |
34 | 37 |
|
35 | 38 | class APIScaffold(Scaffold, ABC): |
36 | 39 | def _do_decorator( |
@@ -174,6 +177,15 @@ def get( |
174 | 177 | doc_ui: Add openapi document UI(swagger, rapidoc and redoc). Defaults to True. |
175 | 178 | """ |
176 | 179 |
|
| 180 | + if extra_form is not None: |
| 181 | + warnings.warn( |
| 182 | + """`extra_form` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 183 | + DeprecationWarning) |
| 184 | + if extra_body is not None: |
| 185 | + warnings.warn( |
| 186 | + """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 187 | + DeprecationWarning) |
| 188 | + |
177 | 189 | def decorator(func) -> Callable: |
178 | 190 | header, cookie, path, query, form, body = \ |
179 | 191 | self._do_decorator( |
@@ -245,6 +257,14 @@ def post( |
245 | 257 | openapi_extensions: Allows extensions to the OpenAPI Schema. |
246 | 258 | doc_ui: Declares this operation to be shown. |
247 | 259 | """ |
| 260 | + if extra_form is not None: |
| 261 | + warnings.warn( |
| 262 | + """`extra_form` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 263 | + DeprecationWarning) |
| 264 | + if extra_body is not None: |
| 265 | + warnings.warn( |
| 266 | + """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 267 | + DeprecationWarning) |
248 | 268 |
|
249 | 269 | def decorator(func) -> Callable: |
250 | 270 | header, cookie, path, query, form, body = \ |
@@ -317,6 +337,14 @@ def put( |
317 | 337 | openapi_extensions: Allows extensions to the OpenAPI Schema. |
318 | 338 | doc_ui: Declares this operation to be shown. |
319 | 339 | """ |
| 340 | + if extra_form is not None: |
| 341 | + warnings.warn( |
| 342 | + """`extra_form` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 343 | + DeprecationWarning) |
| 344 | + if extra_body is not None: |
| 345 | + warnings.warn( |
| 346 | + """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 347 | + DeprecationWarning) |
320 | 348 |
|
321 | 349 | def decorator(func) -> Callable: |
322 | 350 | header, cookie, path, query, form, body = \ |
@@ -389,6 +417,14 @@ def delete( |
389 | 417 | openapi_extensions: Allows extensions to the OpenAPI Schema. |
390 | 418 | doc_ui: Declares this operation to be shown. |
391 | 419 | """ |
| 420 | + if extra_form is not None: |
| 421 | + warnings.warn( |
| 422 | + """`extra_form` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 423 | + DeprecationWarning) |
| 424 | + if extra_body is not None: |
| 425 | + warnings.warn( |
| 426 | + """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 427 | + DeprecationWarning) |
392 | 428 |
|
393 | 429 | def decorator(func) -> Callable: |
394 | 430 | header, cookie, path, query, form, body = \ |
@@ -461,6 +497,14 @@ def patch( |
461 | 497 | openapi_extensions: Allows extensions to the OpenAPI Schema. |
462 | 498 | doc_ui: Declares this operation to be shown. |
463 | 499 | """ |
| 500 | + if extra_form is not None: |
| 501 | + warnings.warn( |
| 502 | + """`extra_form` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 503 | + DeprecationWarning) |
| 504 | + if extra_body is not None: |
| 505 | + warnings.warn( |
| 506 | + """`extra_body` will be deprecated in v3.x, please use `openapi_extra` instead.""", |
| 507 | + DeprecationWarning) |
464 | 508 |
|
465 | 509 | def decorator(func) -> Callable: |
466 | 510 | header, cookie, path, query, form, body = \ |
|
0 commit comments