浏览代码

add simple tags for endpoints in autogenerated doc

Guénaël Muller 7 年前
父节点
当前提交
421742049c

+ 5 - 3
tracim/views/core_api/session_controller.py 查看文件

16
 from tracim.exceptions import NotAuthenticated
16
 from tracim.exceptions import NotAuthenticated
17
 from tracim.exceptions import AuthenticationFailed
17
 from tracim.exceptions import AuthenticationFailed
18
 
18
 
19
+SESSION_ENDPOINTS_TAG = 'Session'
20
+
19
 
21
 
20
 class SessionController(Controller):
22
 class SessionController(Controller):
21
 
23
 
22
-    @hapic.with_api_doc()
24
+    @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
23
     @hapic.input_headers(LoginOutputHeaders())
25
     @hapic.input_headers(LoginOutputHeaders())
24
     @hapic.input_body(BasicAuthSchema())
26
     @hapic.input_body(BasicAuthSchema())
25
     @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
27
     @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
42
         user = uapi.authenticate_user(login.email, login.password)
44
         user = uapi.authenticate_user(login.email, login.password)
43
         return uapi.get_user_with_context(user)
45
         return uapi.get_user_with_context(user)
44
 
46
 
45
-    @hapic.with_api_doc()
47
+    @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
46
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
48
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
47
     def logout(self, context, request: TracimRequest, hapic_data=None):
49
     def logout(self, context, request: TracimRequest, hapic_data=None):
48
         """
50
         """
51
 
53
 
52
         return
54
         return
53
 
55
 
54
-    @hapic.with_api_doc()
56
+    @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
55
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
57
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
56
     @hapic.output_body(UserSchema(),)
58
     @hapic.output_body(UserSchema(),)
57
     def whoami(self, context, request: TracimRequest, hapic_data=None):
59
     def whoami(self, context, request: TracimRequest, hapic_data=None):

+ 3 - 2
tracim/views/core_api/system_controller.py 查看文件

18
 from tracim.views.core_api.schemas import ApplicationSchema
18
 from tracim.views.core_api.schemas import ApplicationSchema
19
 from tracim.views.core_api.schemas import ContentTypeSchema
19
 from tracim.views.core_api.schemas import ContentTypeSchema
20
 
20
 
21
+SYSTEM_ENDPOINTS_TAG = 'System'
21
 
22
 
22
 class SystemController(Controller):
23
 class SystemController(Controller):
23
 
24
 
24
-    @hapic.with_api_doc()
25
+    @hapic.with_api_doc(tags=[SYSTEM_ENDPOINTS_TAG])
25
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
26
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
26
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
27
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
27
     @require_profile(Group.TIM_USER)
28
     @require_profile(Group.TIM_USER)
32
         """
33
         """
33
         return applications
34
         return applications
34
 
35
 
35
-    @hapic.with_api_doc()
36
+    @hapic.with_api_doc(tags=[SYSTEM_ENDPOINTS_TAG])
36
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
37
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
37
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
38
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
38
     @require_profile(Group.TIM_USER)
39
     @require_profile(Group.TIM_USER)

+ 3 - 1
tracim/views/core_api/user_controller.py 查看文件

20
 from tracim.views.core_api.schemas import UserIdPathSchema
20
 from tracim.views.core_api.schemas import UserIdPathSchema
21
 from tracim.views.core_api.schemas import WorkspaceDigestSchema
21
 from tracim.views.core_api.schemas import WorkspaceDigestSchema
22
 
22
 
23
+USERS_ENDPOINTS_TAG = 'Users'
24
+
23
 
25
 
24
 class UserController(Controller):
26
 class UserController(Controller):
25
 
27
 
26
-    @hapic.with_api_doc()
28
+    @hapic.with_api_doc(tags=[USERS_ENDPOINTS_TAG])
27
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
29
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
28
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
30
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
29
     @hapic.handle_exception(UserDoesNotExist, HTTPStatus.NOT_FOUND)
31
     @hapic.handle_exception(UserDoesNotExist, HTTPStatus.NOT_FOUND)

+ 11 - 9
tracim/views/core_api/workspace_controller.py 查看文件

35
 from tracim.models.contents import ContentTypeLegacy as ContentType
35
 from tracim.models.contents import ContentTypeLegacy as ContentType
36
 from tracim.models.revision_protection import new_revision
36
 from tracim.models.revision_protection import new_revision
37
 
37
 
38
+WORKSPACES_ENDPOINTS_TAG = 'Workspaces'
39
+
38
 
40
 
39
 class WorkspaceController(Controller):
41
 class WorkspaceController(Controller):
40
 
42
 
41
-    @hapic.with_api_doc()
43
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
42
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
44
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
43
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
45
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
44
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
46
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
58
         )
60
         )
59
         return wapi.get_workspace_with_context(request.current_workspace)
61
         return wapi.get_workspace_with_context(request.current_workspace)
60
 
62
 
61
-    @hapic.with_api_doc()
63
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
62
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
64
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
63
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
65
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
64
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
66
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
87
             for user_role in roles
89
             for user_role in roles
88
         ]
90
         ]
89
 
91
 
90
-    @hapic.with_api_doc()
92
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
91
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
93
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
92
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
94
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
93
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
95
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
123
         ]
125
         ]
124
         return contents
126
         return contents
125
 
127
 
126
-    @hapic.with_api_doc()
128
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
127
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
129
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
128
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
130
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
129
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
131
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
156
         content = api.get_content_in_context(content)
158
         content = api.get_content_in_context(content)
157
         return content
159
         return content
158
 
160
 
159
-    @hapic.with_api_doc()
161
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
160
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
162
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
161
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
163
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
162
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
164
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
215
         )
217
         )
216
         return api.get_content_in_context(updated_content)
218
         return api.get_content_in_context(updated_content)
217
 
219
 
218
-    @hapic.with_api_doc()
220
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
219
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
221
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
220
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
222
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
221
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
223
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
250
             api.delete(content)
252
             api.delete(content)
251
         return
253
         return
252
 
254
 
253
-    @hapic.with_api_doc()
255
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
254
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
256
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
255
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
257
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
256
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
258
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
286
             api.undelete(content)
288
             api.undelete(content)
287
         return
289
         return
288
 
290
 
289
-    @hapic.with_api_doc()
291
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
290
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
292
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
291
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
293
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
292
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
294
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
318
             api.archive(content)
320
             api.archive(content)
319
         return
321
         return
320
 
322
 
321
-    @hapic.with_api_doc()
323
+    @hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
322
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
324
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
323
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
325
     @hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
324
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
326
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)