Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
add simple tags for endpoints in autogenerated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
inkhey committed Jun 20, 2018
1 parent ab4fc62 commit 4217420
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
8 changes: 5 additions & 3 deletions tracim/views/core_api/session_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
from tracim.exceptions import NotAuthenticated
from tracim.exceptions import AuthenticationFailed

SESSION_ENDPOINTS_TAG = 'Session'


class SessionController(Controller):

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
@hapic.input_headers(LoginOutputHeaders())
@hapic.input_body(BasicAuthSchema())
@hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
Expand All @@ -42,7 +44,7 @@ def login(self, context, request: TracimRequest, hapic_data=None):
user = uapi.authenticate_user(login.email, login.password)
return uapi.get_user_with_context(user)

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT) # nopep8
def logout(self, context, request: TracimRequest, hapic_data=None):
"""
Expand All @@ -51,7 +53,7 @@ def logout(self, context, request: TracimRequest, hapic_data=None):

return

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.output_body(UserSchema(),)
def whoami(self, context, request: TracimRequest, hapic_data=None):
Expand Down
5 changes: 3 additions & 2 deletions tracim/views/core_api/system_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
from tracim.views.core_api.schemas import ApplicationSchema
from tracim.views.core_api.schemas import ContentTypeSchema

SYSTEM_ENDPOINTS_TAG = 'System'

class SystemController(Controller):

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[SYSTEM_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@require_profile(Group.TIM_USER)
Expand All @@ -32,7 +33,7 @@ def applications(self, context, request: TracimRequest, hapic_data=None):
"""
return applications

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[SYSTEM_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@require_profile(Group.TIM_USER)
Expand Down
4 changes: 3 additions & 1 deletion tracim/views/core_api/user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
from tracim.views.core_api.schemas import UserIdPathSchema
from tracim.views.core_api.schemas import WorkspaceDigestSchema

USERS_ENDPOINTS_TAG = 'Users'


class UserController(Controller):

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[USERS_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(UserDoesNotExist, HTTPStatus.NOT_FOUND)
Expand Down
20 changes: 11 additions & 9 deletions tracim/views/core_api/workspace_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
from tracim.models.contents import ContentTypeLegacy as ContentType
from tracim.models.revision_protection import new_revision

WORKSPACES_ENDPOINTS_TAG = 'Workspaces'


class WorkspaceController(Controller):

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand All @@ -58,7 +60,7 @@ def workspace(self, context, request: TracimRequest, hapic_data=None):
)
return wapi.get_workspace_with_context(request.current_workspace)

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -87,7 +89,7 @@ def workspaces_members(
for user_role in roles
]

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -123,7 +125,7 @@ def workspace_content(
]
return contents

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -156,7 +158,7 @@ def create_generic_empty_content(
content = api.get_content_in_context(content)
return content

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -215,7 +217,7 @@ def move_content(
)
return api.get_content_in_context(updated_content)

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -250,7 +252,7 @@ def delete_content(
api.delete(content)
return

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -286,7 +288,7 @@ def undelete_content(
api.undelete(content)
return

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down Expand Up @@ -318,7 +320,7 @@ def archive_content(
api.archive(content)
return

@hapic.with_api_doc()
@hapic.with_api_doc(tags=[WORKSPACES_ENDPOINTS_TAG])
@hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
@hapic.handle_exception(InsufficientUserProfile, HTTPStatus.FORBIDDEN)
@hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
Expand Down

0 comments on commit 4217420

Please sign in to comment.