Skip to content

Commit

Permalink
Explain support for optional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
prkumar committed Mar 16, 2019
1 parent 6a6e247 commit 7f51452
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions docs/source/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,28 @@ by method arguments.
@get("users/{username}/repos")
def get_repos(self, username, sort: Query): pass
For "catch-all" or complex query parameter combinations, a
:py:class:`~uplink.QueryMap` can be used:
Setting a default value for the query parameter works like you'd expect
it to:

.. code-block:: python
@get("users/{username}/repos")
def get_repos(self, username, sort: Query = "created"): pass
To make the query parameter optional, set the argument's default value
to :obj:`None`. Then, if the argument is not specified at runtime, the
parameter will not appear in the request.

.. code-block:: python
@get("users/{username}/repos")
def get_repos(self, username, sort: Query = None): pass
Useful for "catch-all" or complex query parameter combinations, the
:py:class:`~uplink.QueryMap` annotation accepts a mapping of query
parameters:

.. code-block:: python
Expand Down

0 comments on commit 7f51452

Please sign in to comment.