-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e3189c
Showing
128 changed files
with
23,050 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 5bad9f5f398c5499f5febea01631b3c9 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
Filtering API example | ||
====================== | ||
|
||
.. literalinclude:: ../examples/custom_filter_example.py | ||
:language: python | ||
|
||
|
||
|
||
Filter by jsonb contains | ||
|
||
.. code-block:: json | ||
[ | ||
{ | ||
"name": "words", | ||
"op": "jsonb_contains", | ||
"val": {"location": "Moscow", "spam": "eggs"} | ||
} | ||
] | ||
Request: | ||
|
||
.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array | ||
:language: HTTP | ||
|
||
Response: | ||
|
||
.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array_result | ||
:language: HTTP | ||
|
||
|
||
Other examples | ||
-------------- | ||
|
||
.. code-block:: python | ||
# pseudo-code | ||
class User: | ||
name: str = ... | ||
words: list[str] = ... | ||
Filter by word | ||
|
||
.. code-block:: json | ||
[ | ||
{ | ||
"name": "words", | ||
"op": "in", | ||
"val": "spam" | ||
} | ||
] | ||
Request: | ||
|
||
.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_in_array | ||
:language: HTTP | ||
|
||
Response: | ||
|
||
.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_in_array_result | ||
:language: HTTP | ||
|
||
|
||
Filter by words | ||
|
||
.. code-block:: json | ||
[ | ||
{ | ||
"name": "words", | ||
"op": "in", | ||
"val": ["bar", "eggs"] | ||
} | ||
] | ||
Request: | ||
|
||
.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_words_in_array | ||
:language: HTTP | ||
|
||
Response: | ||
|
||
.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_words_in_array_result | ||
:language: HTTP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.. _api_limited_methods_example: | ||
|
||
Limit API methods | ||
################# | ||
|
||
Sometimes you won't need all the CRUD methods. | ||
For example, you want to create only GET, POST and GET LIST methods, | ||
so user can't update or delete any items. | ||
|
||
|
||
Set ``methods`` on Routers registration: | ||
|
||
.. code-block:: python | ||
RoutersJSONAPI( | ||
router=router, | ||
path="/users", | ||
tags=["User"], | ||
class_detail=UserDetailView, | ||
class_list=UserListView, | ||
schema=UserSchema, | ||
model=User, | ||
resource_type="user", | ||
methods=[ | ||
RoutersJSONAPI.Methods.GET_LIST, | ||
RoutersJSONAPI.Methods.POST, | ||
RoutersJSONAPI.Methods.GET, | ||
], | ||
) | ||
This will limit generated views to: | ||
|
||
======================== ====== ============= =========================== | ||
URL method endpoint Usage | ||
======================== ====== ============= =========================== | ||
/users GET user_list Get a collection of users | ||
/users POST user_list Create a user | ||
/users/{user_id} GET user_detail Get user details | ||
======================== ====== ============= =========================== | ||
|
||
|
||
Full code example (should run "as is"): | ||
|
||
.. literalinclude:: ../examples/api_limited_methods.py | ||
:language: python |
Oops, something went wrong.