@@ -24,61 +24,61 @@ An example of FastAPI-JSONAPI API looks like this:
2424
2525This example provides the following API:
2626
27- +----------------+--------+----------------+- --------------------------------+
28- | url | method | endpoint | action |
29- +================+========+================+= ================================+
30- | /users | GET | user_list | Retrieve a collection of users |
31- +----------------+--------+----------------+- --------------------------------+
32- | /users | POST | user_list | Create a user |
33- +----------------+--------+----------------+- --------------------------------+
34- | /users/<int:id> | GET | user_detail | Retrieve details of a user |
35- +----------------+--------+----------------+- --------------------------------+
36- | /users/<int:id> | PATCH | user_detail | Update a user |
37- +----------------+--------+----------------+- --------------------------------+
38- | /users/<int:id> | DELETE | user_detail | Delete a user |
39- +----------------+--------+----------------+- --------------------------------+
27+ +----------------- +--------+-------------+ --------------------------------+
28+ | url | method | endpoint | action |
29+ +================= +========+=============+ ================================+
30+ | /users | GET | user_list | Retrieve a collection of users |
31+ +----------------- +--------+-------------+ --------------------------------+
32+ | /users | POST | user_list | Create a user |
33+ +----------------- +--------+-------------+ --------------------------------+
34+ | /users/<int:id> | GET | user_detail | Retrieve details of a user |
35+ +----------------- +--------+-------------+ --------------------------------+
36+ | /users/<int:id> | PATCH | user_detail | Update a user |
37+ +----------------- +--------+-------------+ --------------------------------+
38+ | /users/<int:id> | DELETE | user_detail | Delete a user |
39+ +----------------- +--------+-------------+ --------------------------------+
4040
4141in developing
4242
43- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
44- | url | method | endpoint | action |
45- +=========================================== +========+==================+= =====================================================+
46- | /users/<int:id>/group | GET | computer_list | Retrieve a collection computers related to a user |
47- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
48- | /users/<int:id>/group | POST | computer_list | Create a computer related to a user |
49- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
50- | /users/<int:id>/relationships/group | GET | user_computers | Retrieve relationships between a user and computers |
51- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
52- | /users/<int:id>/relationships/computers | POST | user_computers | Create relationships between a user and computers |
53- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
54- | /users/<int:id>/relationships/computers | PATCH | user_computers | Update relationships between a user and computers |
55- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
56- | /users/<int:id>/relationships/computers | DELETE | user_computers | Delete relationships between a user and computers |
57- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
58- | /computers | GET | computer_list | Retrieve a collection of computers |
59- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
60- | /computers | POST | computer_list | Create a computer |
61- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
62- | /computers/<int:id> | GET | computer_detail | Retrieve details of a computer |
63- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
64- | /computers/<int:id> | PATCH | computer_detail | Update a computer |
65- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
66- | /computers/<int:id> | DELETE | computer_detail | Delete a computer |
67- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
68- | /computers/<int:id>/owner | GET | user_detail | Retrieve details of the owner of a computer |
69- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
70- | /computers/<int:id>/owner | PATCH | user_detail | Update the owner of a computer |
71- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
72- | /computers/<int:id>/owner | DELETE | user_detail | Delete the owner of a computer |
73- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
74- | /computers/<int:id>/relationships/owner | GET | user_computers | Retrieve relationships between a user and computers |
75- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
76- | /computers/<int:id>/relationships/owner | POST | user_computers | Create relationships between a user and computers |
77- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
78- | /computers/<int:id>/relationships/owner | PATCH | user_computers | Update relationships between a user and computers |
79- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
80- | /computers/<int:id>/relationships/owner | DELETE | user_computers | Delete relationships between a user and computers |
81- +------------------------------------------- +--------+------------------+- -----------------------------------------------------+
43+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
44+ | url | method | endpoint | action |
45+ +=========================================+========+=================+ =====================================================+
46+ | /users/<int:id>/group | GET | computer_list | Retrieve a collection computers related to a user |
47+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
48+ | /users/<int:id>/group | POST | computer_list | Create a computer related to a user |
49+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
50+ | /users/<int:id>/relationships/group | GET | user_computers | Retrieve relationships between a user and computers |
51+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
52+ | /users/<int:id>/relationships/computers | POST | user_computers | Create relationships between a user and computers |
53+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
54+ | /users/<int:id>/relationships/computers | PATCH | user_computers | Update relationships between a user and computers |
55+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
56+ | /users/<int:id>/relationships/computers | DELETE | user_computers | Delete relationships between a user and computers |
57+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
58+ | /computers | GET | computer_list | Retrieve a collection of computers |
59+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
60+ | /computers | POST | computer_list | Create a computer |
61+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
62+ | /computers/<int:id> | GET | computer_detail | Retrieve details of a computer |
63+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
64+ | /computers/<int:id> | PATCH | computer_detail | Update a computer |
65+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
66+ | /computers/<int:id> | DELETE | computer_detail | Delete a computer |
67+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
68+ | /computers/<int:id>/owner | GET | user_detail | Retrieve details of the owner of a computer |
69+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
70+ | /computers/<int:id>/owner | PATCH | user_detail | Update the owner of a computer |
71+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
72+ | /computers/<int:id>/owner | DELETE | user_detail | Delete the owner of a computer |
73+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
74+ | /computers/<int:id>/relationships/owner | GET | user_computers | Retrieve relationships between a user and computers |
75+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
76+ | /computers/<int:id>/relationships/owner | POST | user_computers | Create relationships between a user and computers |
77+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
78+ | /computers/<int:id>/relationships/owner | PATCH | user_computers | Update relationships between a user and computers |
79+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
80+ | /computers/<int:id>/relationships/owner | DELETE | user_computers | Delete relationships between a user and computers |
81+ +-----------------------------------------+--------+-----------------+ -----------------------------------------------------+
8282
8383
8484Save `this file <https://github.com/mts-ai/FastAPI-JSONAPI/blob/main/examples/api_for_sqlalchemy/main.py >`_ as api.py and run it using your Python interpreter. Note that we've enabled
@@ -154,13 +154,11 @@ Response:
154154Relationships
155155-------------
156156
157- | Now let's use relationships tools.
158- | First, create 3 computers named "Halo", "Nestor" and "Commodore".
159- |
160- | Done?
161- | Ok. So let's continue this tutorial.
162- |
163- | We assume that Halo has id=2, Nestor id=3 and Commodore id=4.
157+ .. note ::
158+ Now let's use relationships tools.
159+ First, create 3 computers named "Halo", "Nestor" and "Commodore".
160+ We assume that Halo has id=2, Nestor id=3 and Commodore id=4.
161+
164162
165163Create object with related object(s)
166164~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments