Closed Naramsim closed 4 months ago
Howdy @Naramsim! :open_mouth: I wrote a similar thing yesterday.
It seems that nothing is being generated from this change when I run make openapi-generate
.
However @ryu-0729's PR #1050, has a solution. see api.py ln 75
#...
retrieve_path_parameter = OpenApiParameter(
name="id",
description="This parameter can be a string or an integer.",
location=OpenApiParameter.PATH,
type=OpenApiTypes.STR,
required=True,
)
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,
)
#...
@extend_schema(
description="Pokémon are the creatures that inhabit the world of the Pokémon games. They can be caught using Pokéballs and trained by battling with other Pokémon. Each Pokémon belongs to a specific species but may take on a variant which makes it differ from other Pokémon of the same species, such as base stats, available abilities and typings. See [Bulbapedia](http://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_(species)) for greater detail.",
summary="Get pokemon",
tags=["pokemon"],
)
@extend_schema_view(
list=extend_schema(summary="List pokemon", parameters=[q_query_string_parameter]),
)
class PokemonResource(PokeapiCommonViewset):
queryset = Pokemon.objects.all()
serializer_class = PokemonDetailSerializer
list_serializer_class = PokemonSummarySerializer
@extend_schema(parameters=[retrieve_path_parameter])
def retrieve(self, request, pk=None):
return super().retrieve(request, pk)
#...
sorry about the tint I have night shift on
If you have the same feature but working, you can submit your PR and I'll close this one
Yeah, I'll try to post a PR today or tomorrow.
@Naramsim does the 'q' param apply to all list endpoints?
@Naramsim does the 'q' param apply to all list endpoints?
Yes it seems so! It would be nice to test it on unnamed resources, those that only support querying by ID.
@Indyandie could you review this PR? Thanks!