Skip to content

Commit

Permalink
added missing swaggers
Browse files Browse the repository at this point in the history
  • Loading branch information
terazus committed Aug 1, 2023
1 parent 721e166 commit e38dbfd
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ptmd/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def reset_pwd(token: str) -> tuple[Response, int]:
return reset_password(token)


# TODO: Add missing swagger for this route
@app.route("/api/users/<user_id>/make_admin", methods=["GET"])
@swag_from(path.join(USERS_DOC_PATH, 'make_admin.yml'))
@jwt_required()
def make_admin_(user_id: int) -> tuple[Response, int]:
def make_admin(user_id: int) -> tuple[Response, int]:
""" Route to make a user an admin. This is an admin only route
:param user_id: the id of the user to make admin
Expand All @@ -131,6 +131,7 @@ def make_admin_(user_id: int) -> tuple[Response, int]:


@app.route("/api/users/<user_id>/ban", methods=["GET"])
@swag_from(path.join(USERS_DOC_PATH, 'ban_user.yml'))
@jwt_required()
def ban_user(user_id: int) -> tuple[Response, int]:
""" Route to ban a user. This is an admin only route
Expand All @@ -142,6 +143,7 @@ def ban_user(user_id: int) -> tuple[Response, int]:


@app.route("/api/users/<user_id>", methods=["DELETE"])
@swag_from(path.join(USERS_DOC_PATH, 'delete_user.yml'))
@jwt_required()
def delete_user_(user_id: int) -> tuple[Response, int]:
""" Route to delete a user. Admin or user only route
Expand Down
29 changes: 29 additions & 0 deletions ptmd/resources/api/users/ban_user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The route to you change the current user password
---
parameters:
- name: Authorization
in: header
required: true
type: string
description: The JWT token
- name: user_id
in: path
required: true
type: integer
description: The user id
definitions:
Ban User:
type: string
description: message to confirm the user was made admin
example: User 2 role has been changed to banned
responses:
200:
description: The user data with that JWT token
properties:
changed:
type: boolean
description: True if the password was changed
401:
description: The JWT token is missing or invalid
schema:
$ref: '#/definitions/Missing Bearer Response'
29 changes: 29 additions & 0 deletions ptmd/resources/api/users/delete_user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The route to you change the current user password
---
parameters:
- name: Authorization
in: header
required: true
type: string
description: The JWT token
- name: user_id
in: path
required: true
type: integer
description: The user id
definitions:
Delete User:
type: string
description: message to confirm the user deletion
example: User 2 deleted
responses:
200:
description: The user data with that JWT token
properties:
changed:
type: boolean
description: True if the password was changed
401:
description: The JWT token is missing or invalid
schema:
$ref: '#/definitions/Missing Bearer Response'
29 changes: 29 additions & 0 deletions ptmd/resources/api/users/make_admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The route to you change the current user password
---
parameters:
- name: Authorization
in: header
required: true
type: string
description: The JWT token
- name: user_id
in: path
required: true
type: integer
description: The user id
definitions:
Make User Admin:
type: string
description: message to confirm the user was made admin
example: User 2 role has been changed to admin
responses:
200:
description: The user data with that JWT token
properties:
changed:
type: boolean
description: True if the password was changed
401:
description: The JWT token is missing or invalid
schema:
$ref: '#/definitions/Missing Bearer Response'

0 comments on commit e38dbfd

Please sign in to comment.