Skip to content

Query q OAS descriptor#1078

Closed
Naramsim wants to merge 1 commit intomasterfrom
openapi-naram
Closed

Query q OAS descriptor#1078
Naramsim wants to merge 1 commit intomasterfrom
openapi-naram

Conversation

@Naramsim
Copy link
Copy Markdown
Member

@Naramsim Naramsim commented May 6, 2024

@Indyandie could you review this PR? Thanks!

@Naramsim Naramsim added the no-deploy Instructs the updater-bot not to deploy this PR label May 7, 2024
@Indyandie
Copy link
Copy Markdown
Contributor

Howdy @Naramsim! 😮 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)

#...

@Indyandie
Copy link
Copy Markdown
Contributor

Indyandie commented May 9, 2024

sorry about the tint I have night shift on

2024-05-09T01:06:43CDT-img

@Naramsim
Copy link
Copy Markdown
Member Author

Naramsim commented May 9, 2024

If you have the same feature but working, you can submit your PR and I'll close this one

@Indyandie
Copy link
Copy Markdown
Contributor

Yeah, I'll try to post a PR today or tomorrow.

@Naramsim does the 'q' param apply to all list endpoints?

@Naramsim
Copy link
Copy Markdown
Member Author

@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.

@Naramsim Naramsim closed this May 12, 2024
@Naramsim Naramsim deleted the openapi-naram branch May 12, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-deploy Instructs the updater-bot not to deploy this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants