mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-22 03:13:06 +00:00
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:
commit
fa9aa4f107
3 changed files with 401 additions and 224 deletions
16
default.nix
16
default.nix
|
@ -1,22 +1,11 @@
|
||||||
with import <nixpkgs> { };
|
with import <nixpkgs> { };
|
||||||
|
pkgs.mkShell {
|
||||||
let
|
name = "onix-shellder";
|
||||||
pythonPackages = python3Packages;
|
|
||||||
in pkgs.mkShell rec {
|
|
||||||
name = "impurePythonEnv";
|
|
||||||
venvDir = "./.venv";
|
venvDir = "./.venv";
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
python310Packages.python
|
python310Packages.python
|
||||||
python310Packages.venvShellHook
|
python310Packages.venvShellHook
|
||||||
|
|
||||||
# python310Packages.coverage
|
|
||||||
# python310Packages.python-mimeparse
|
|
||||||
# python310Packages.python-dateutil
|
|
||||||
# python310Packages.drf-spectacular
|
|
||||||
# python310Packages.djangorestframework
|
|
||||||
# python310Packages.django-redis
|
|
||||||
# python310Packages.django-cors-headers
|
|
||||||
|
|
||||||
# Required dependancies
|
# Required dependancies
|
||||||
black
|
black
|
||||||
taglib
|
taglib
|
||||||
|
@ -37,6 +26,7 @@ in pkgs.mkShell rec {
|
||||||
postShellHook = ''
|
postShellHook = ''
|
||||||
# allow pip to install wheels
|
# allow pip to install wheels
|
||||||
unset SOURCE_DATE_EPOCH
|
unset SOURCE_DATE_EPOCH
|
||||||
|
zsh -l
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
576
openapi.yml
576
openapi.yml
File diff suppressed because it is too large
Load diff
|
@ -50,16 +50,6 @@ class NameOrIdRetrieval:
|
||||||
|
|
||||||
return queryset
|
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):
|
def get_object(self):
|
||||||
queryset = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
queryset = self.filter_queryset(queryset)
|
queryset = self.filter_queryset(queryset)
|
||||||
|
@ -81,9 +71,30 @@ class NameOrIdRetrieval:
|
||||||
return resp
|
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(
|
class PokeapiCommonViewset(
|
||||||
ListOrDetailSerialRelation, NameOrIdRetrieval, viewsets.ReadOnlyModelViewSet
|
ListOrDetailSerialRelation, NameOrIdRetrieval, viewsets.ReadOnlyModelViewSet
|
||||||
):
|
):
|
||||||
|
@extend_schema(parameters=[retrieve_path_parameter])
|
||||||
|
def retrieve(self, request, pk=None):
|
||||||
|
return super().retrieve(request, pk)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -734,7 +745,7 @@ class PokemonShapeResource(PokeapiCommonViewset):
|
||||||
@extend_schema_view(
|
@extend_schema_view(
|
||||||
list=extend_schema(
|
list=extend_schema(
|
||||||
summary="List pokemon",
|
summary="List pokemon",
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
class PokemonResource(PokeapiCommonViewset):
|
class PokemonResource(PokeapiCommonViewset):
|
||||||
queryset = Pokemon.objects.all()
|
queryset = Pokemon.objects.all()
|
||||||
|
|
Loading…
Reference in a new issue