Skip to content

Commit

Permalink
add missing usage case to type hints #418
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Jun 4, 2021
1 parent acd8974 commit 226d450
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ discovered in the introspection.
class PersonView(viewsets.GenericViewSet):
@extend_schema(
parameters=[
QuerySerializer, # serializer fields is converted parameters
OpenApiParameter("nested", QuerySerializer), # serializer object is converted parameter
QuerySerializer, # serializer fields are converted to parameters
OpenApiParameter("nested", QuerySerializer), # serializer object is converted to a parameter
OpenApiParameter("queryparam1", OpenApiTypes.UUID, OpenApiParameter.QUERY),
OpenApiParameter("pk", OpenApiTypes.UUID, OpenApiParameter.PATH), # path variable was overridden
],
Expand Down
4 changes: 2 additions & 2 deletions drf_spectacular/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(

def extend_schema(
operation_id: Optional[str] = None,
parameters: Optional[List[OpenApiParameter]] = None,
parameters: Optional[List[Union[OpenApiParameter, _SerializerType]]] = None,
request: Any = empty,
responses: Any = empty,
auth: Optional[List[str]] = None,
Expand Down Expand Up @@ -366,7 +366,7 @@ def get_tags(self):


def extend_schema_field(
field: Union[_SerializerTypeVariations, Dict],
field: Union[_SerializerTypeVariations, Field, Dict],
component_name: Optional[str] = None
):
"""
Expand Down
1 change: 1 addition & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ pytest-django>=3.8.0
pytest-cov>=2.8.1
flake8>=3.7.9
mypy>=0.770
django-stubs>=1.8.0
djangorestframework-stubs>=1.1.0
isort>=5.0.4
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ include_trailing_comma = true

[mypy]
python_version = 3.6
plugins = mypy_django_plugin.main,mypy_drf_plugin.main

[mypy.plugins.django-stubs]
django_settings_module = "tests.settings"

[mypy-rest_framework.compat.*]
ignore_missing_imports = True
Expand Down Expand Up @@ -119,3 +123,9 @@ ignore_missing_imports = True

[mypy-django_filters.*]
ignore_missing_imports = True

[mypy-polymorphic.*]
ignore_missing_imports = True

[mypy-rest_polymorphic.*]
ignore_missing_imports = True

0 comments on commit 226d450

Please sign in to comment.