Merge pull request #1087 from Indyandie/docs/q_query_string_param

docs(openapi): `q` query string param, fix `id` path parameter, nix refactor
This commit is contained in:
Alessandro Pezzè 2024-05-12 19:24:36 +02:00 committed by GitHub
commit fa9aa4f107
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 401 additions and 224 deletions

View file

@ -1,22 +1,11 @@
with import <nixpkgs> { };
let
pythonPackages = python3Packages;
in pkgs.mkShell rec {
name = "impurePythonEnv";
pkgs.mkShell {
name = "onix-shellder";
venvDir = "./.venv";
buildInputs = [
python310Packages.python
python310Packages.venvShellHook
# python310Packages.coverage
# python310Packages.python-mimeparse
# python310Packages.python-dateutil
# python310Packages.drf-spectacular
# python310Packages.djangorestframework
# python310Packages.django-redis
# python310Packages.django-cors-headers
# Required dependancies
black
taglib
@ -37,6 +26,7 @@ in pkgs.mkShell rec {
postShellHook = ''
# allow pip to install wheels
unset SOURCE_DATE_EPOCH
zsh -l
'';
}

File diff suppressed because it is too large Load diff

View file

@ -50,16 +50,6 @@ class NameOrIdRetrieval:
return queryset
@extend_schema(
parameters=[
OpenApiParameter(
name="id",
description="This parameter can be a string or an integer.",
location=OpenApiParameter.PATH,
type=OpenApiTypes.STR,
),
]
)
def get_object(self):
queryset = self.get_queryset()
queryset = self.filter_queryset(queryset)
@ -81,9 +71,30 @@ class NameOrIdRetrieval:
return resp
q_query_string_parameter = OpenApiParameter(
name="q",
description="> Only available locally and not at [pokeapi.co](https://pokeapi.co/docs/v2)\nCase-insensitive query applied on the `name` property. ",
location=OpenApiParameter.QUERY,
type=OpenApiTypes.STR,
)
retrieve_path_parameter = OpenApiParameter(
name="id",
description="This parameter can be a string or an integer.",
location=OpenApiParameter.PATH,
type=OpenApiTypes.STR,
required=True,
)
@extend_schema_view(list=extend_schema(parameters=[q_query_string_parameter]))
class PokeapiCommonViewset(
ListOrDetailSerialRelation, NameOrIdRetrieval, viewsets.ReadOnlyModelViewSet
):
@extend_schema(parameters=[retrieve_path_parameter])
def retrieve(self, request, pk=None):
return super().retrieve(request, pk)
pass
@ -734,7 +745,7 @@ class PokemonShapeResource(PokeapiCommonViewset):
@extend_schema_view(
list=extend_schema(
summary="List pokemon",
)
),
)
class PokemonResource(PokeapiCommonViewset):
queryset = Pokemon.objects.all()