Skip to content

Commit

Permalink
deploy: 64b0b17
Browse files Browse the repository at this point in the history
  • Loading branch information
mahenzon committed Apr 27, 2024
0 parents commit 2e3189c
Show file tree
Hide file tree
Showing 128 changed files with 23,050 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
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 added .doctrees/api_filtering_example.doctree
Binary file not shown.
Binary file added .doctrees/api_limited_methods_example.doctree
Binary file not shown.
Binary file added .doctrees/atomic_operations.doctree
Binary file not shown.
Binary file added .doctrees/changelog.doctree
Binary file not shown.
Binary file added .doctrees/client_generated_id.doctree
Binary file not shown.
Binary file added .doctrees/configuration.doctree
Binary file not shown.
Binary file added .doctrees/custom_sql_filtering.doctree
Binary file not shown.
Binary file added .doctrees/data_layer.doctree
Binary file not shown.
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file added .doctrees/errors.doctree
Binary file not shown.
Binary file added .doctrees/fastapi-jsonapi.doctree
Binary file not shown.
Binary file added .doctrees/filtering.doctree
Binary file not shown.
Binary file added .doctrees/include_many_to_many.doctree
Binary file not shown.
Binary file added .doctrees/include_related_objects.doctree
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
Binary file added .doctrees/installation.doctree
Binary file not shown.
Binary file added .doctrees/logical_data_abstraction.doctree
Binary file not shown.
Binary file added .doctrees/minimal_api_example.doctree
Binary file not shown.
Binary file added .doctrees/minimal_api_head.doctree
Binary file not shown.
Binary file added .doctrees/oauth.doctree
Binary file not shown.
Binary file added .doctrees/pagination.doctree
Binary file not shown.
Binary file added .doctrees/permission.doctree
Binary file not shown.
Binary file added .doctrees/quickstart.doctree
Binary file not shown.
Binary file added .doctrees/relationships.doctree
Binary file not shown.
Binary file added .doctrees/routing.doctree
Binary file not shown.
Binary file added .doctrees/sorting.doctree
Binary file not shown.
Binary file added .doctrees/sparse_fieldsets.doctree
Binary file not shown.
Binary file added .doctrees/updated_includes_example.doctree
Binary file not shown.
Binary file added .doctrees/view_dependencies.doctree
Binary file not shown.
Empty file added .nojekyll
Empty file.
Binary file added _images/schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions _sources/api_filtering_example.rst.txt
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
46 changes: 46 additions & 0 deletions _sources/api_limited_methods_example.rst.txt
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
Loading

0 comments on commit 2e3189c

Please sign in to comment.