From 28f9079f4a1909f277a47f0d45be1f82a84de27d Mon Sep 17 00:00:00 2001 From: Saranya Jena Date: Fri, 28 Jul 2023 13:48:18 +0800 Subject: [PATCH] Added swagger.json file for auth APIs (#4103) * Added swagger.json file for auth APIs Signed-off-by: Saranya-jena * updated api fielda from snake case to camel case Signed-off-by: Saranya-jena * test commit to check if required field is working Signed-off-by: Saranya-jena * updated required fields correctly Signed-off-by: Saranya-jena --------- Signed-off-by: Saranya-jena --- .../api/handlers/rest/user_handlers.go | 10 +- .../authentication/api/presenter/rest.go | 2 +- .../authentication/api/routes/user_router.go | 4 +- .../authentication/pkg/project/repository.go | 3 + mkdocs/docs/auth/v3.0.0/auth-api.json | 1295 +++++++++++++++++ 5 files changed, 1306 insertions(+), 8 deletions(-) create mode 100644 mkdocs/docs/auth/v3.0.0/auth-api.json diff --git a/chaoscenter/authentication/api/handlers/rest/user_handlers.go b/chaoscenter/authentication/api/handlers/rest/user_handlers.go index 023a2add707..e3058678264 100644 --- a/chaoscenter/authentication/api/handlers/rest/user_handlers.go +++ b/chaoscenter/authentication/api/handlers/rest/user_handlers.go @@ -251,11 +251,11 @@ func LoginUser(service services.ApplicationService) gin.HandlerFunc { } c.JSON(200, gin.H{ - "access_token": token, - "project_id": defaultProject, - "project_role": entities.RoleOwner, - "expires_in": expiryTime, - "type": "Bearer", + "accessToken": token, + "projectID": defaultProject, + "projectRole": entities.RoleOwner, + "expiresIn": expiryTime, + "type": "Bearer", }) } } diff --git a/chaoscenter/authentication/api/presenter/rest.go b/chaoscenter/authentication/api/presenter/rest.go index cfa8addabd0..18fe6aa57aa 100644 --- a/chaoscenter/authentication/api/presenter/rest.go +++ b/chaoscenter/authentication/api/presenter/rest.go @@ -5,7 +5,7 @@ import "github.com/litmuschaos/litmus/chaoscenter/authentication/pkg/utils" // ErrorResponseStruct defines the structure for error responses type ErrorResponseStruct struct { Error string `json:"error"` - ErrorDescription string `json:"error_description"` + ErrorDescription string `json:"errorDescription"` } // CreateErrorResponse is a helper function that creates a ErrorResponseStruct diff --git a/chaoscenter/authentication/api/routes/user_router.go b/chaoscenter/authentication/api/routes/user_router.go index e65d46f54b9..4d9fa806117 100644 --- a/chaoscenter/authentication/api/routes/user_router.go +++ b/chaoscenter/authentication/api/routes/user_router.go @@ -14,9 +14,9 @@ func UserRouter(router *gin.Engine, service services.ApplicationService) { router.Use(middleware.JwtMiddleware()) router.POST("/update/password", rest.UpdatePassword(service)) router.POST("/reset/password", rest.ResetPassword(service)) - router.POST("/create", rest.CreateUser(service)) + router.POST("/create_user", rest.CreateUser(service)) router.POST("/update/details", rest.UpdateUser(service)) - router.GET("/getUser/:uid", rest.GetUser(service)) + router.GET("/get_user/:uid", rest.GetUser(service)) router.GET("/users", rest.FetchUsers(service)) router.GET("/invite_users/:project_id", rest.InviteUsers(service)) router.POST("/update/state", rest.UpdateUserState(service)) diff --git a/chaoscenter/authentication/pkg/project/repository.go b/chaoscenter/authentication/pkg/project/repository.go index 9d2a9db0433..8884a42a4e0 100644 --- a/chaoscenter/authentication/pkg/project/repository.go +++ b/chaoscenter/authentication/pkg/project/repository.go @@ -458,6 +458,9 @@ func (r repository) GetProjectMembers(projectID string, state string) ([]*entiti return nil, err } + if len(res) <= 0 { + return nil, nil + } return res[0].Members, nil } diff --git a/mkdocs/docs/auth/v3.0.0/auth-api.json b/mkdocs/docs/auth/v3.0.0/auth-api.json new file mode 100644 index 00000000000..76a751219f2 --- /dev/null +++ b/mkdocs/docs/auth/v3.0.0/auth-api.json @@ -0,0 +1,1295 @@ +{ + "swagger": "2.0", + "host": "localhost:3000", + "schemes": ["https", "http"], + "info": { + "title": "Litmus Portal Authentication API", + "version": "2.7.0", + "description": "Litmus Portal Authentication APIs are used to authenticate the identity of a user and to perform several user-specific tasks like:\n
  • Update Profile
  • \n
  • Change Password
  • \n
  • Reset Password
  • \n
  • Create new users etc.
  • \n" + }, + "paths": { + "/status": { + "get": { + "description": "This API is used to check the status of the server.", + "operationId": "status", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "status": "up" + } + }, + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string" + } + } + } + } + }, + "parameters": [], + "produces": ["application/json"] + } + }, + "/login": { + "post": { + "description": "This API is used to login into auth server.", + "operationId": "login", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjcxMjY4MjMsInJvbGUiOiJhZG1pbiIsInVpZCI6ImY4MDM2YzUxLTBkNzktNGNkNy1hN2QwLTQ1ZGNhZGI4MGVlYiIsInVzZXJuYW1lIjoiYWRtaW4ifQ.zNIMwocHgmguwtGFupV54UfcfwEdaRO1_xB2ilalqn0fp-JE0ujkHT3gDyepnEGSRm2j1eTopPgtvyRVPb7gGA", + "expires_in": 86400, + "type": "Bearer" + } + }, + "schema": { + "$ref": "#/definitions/LoginResponse" + } + }, + "401": { + "description": "Unauthorized", + "examples": { + "application/json": { + "error": "unauthorized", + "error_description": "The user does not have requested authorization to access this resource" + } + }, + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["username", "password"], + "properties": { + "username": { + "type": "string" + }, + "password": { + "type": "string" + } + }, + "example": { + "username": "admin", + "password": "admin" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/users": { + "get": { + "description": "This API is used to get the list of users", + "operationId": "users", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": [ + { + "_id": "f8036c51-0d79-4cd7-a7d0-45dcadb80eeb", + "username": "admin", + "email": "user1@litmus.com", + "name": "user1", + "role": "admin", + "created_at": "1627040098" + } + ] + }, + "schema": { + "$ref": "#/definitions/Users" + } + } + }, + "parameters": [], + "produces": ["application/json"] + } + }, + "/get_user/{user_id}": { + "get": { + "description": "This API is used to get the details of an user by passing uid in the URL", + "operationId": "getUser", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "_id": "f8036c51-0d79-4cd7-a7d0-45dcadb80eeb", + "username": "admin", + "email": "user1@litmus.com", + "name": "user1", + "role": "admin", + "created_at": "1627040098" + } + }, + "schema": { + "$ref": "#/definitions/User" + } + } + }, + "parameters": [ + { + "name": "user_id", + "required": true, + "description": "ID of the user", + "in": "path", + "type": "string" + } + ], + "produces": ["application/json"] + } + }, + "/update/password": { + "post": { + "description": "This API is used to update the password", + "operationId": "updatePassword", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "password has been reset" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["username", "oldPassword", "newPassword"], + "properties": { + "username": { + "type": "string" + }, + "oldPassword": { + "type": "string" + }, + "newPassword": { + "type": "string" + } + }, + "example": { + "username": "admin", + "oldPassword": "admin", + "newPassword": "litmus" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/create_user": { + "post": { + "description": "This API is used to create a new user.", + "operationId": "createUser", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "_id": "5873815a-1535-4b1c-8766-2fe53c726276", + "username": "test1", + "email": "test1@litmus.com", + "name": "Test Account", + "role": "admin", + "created_at": "1627040799" + } + }, + "schema": { + "$ref": "#/definitions/User" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "required": ["username", "password", "role"], + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "role": { + "type": "string" + }, + "email": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "example": { + "username": "test1", + "password": "test1", + "role": "admin", + "email": "test1@litmus.com", + "name": "Test Account" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/reset/password": { + "post": { + "description": "This API is used to reset the password of a user.", + "operationId": "resetPassword", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "password has been reset successfully" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["username", "oldPassword", "newPassword"], + "properties": { + "username": { + "type": "string" + }, + "oldPassword": { + "type": "string" + }, + "newPassword": { + "type": "string" + } + }, + "example": { + "username": "test1", + "new_password": "test2" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/update/details": { + "post": { + "description": "This API is used to update the details of a user.", + "operationId": "updateDetails", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "User details updated successfully" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "email": { + "type": "string" + } + }, + "example": { + "name": "Administrator", + "email": "admin@litmus.com" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/update/state": { + "post": { + "description": "This API is used to update the state of a user.", + "operationId": "updateState", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "user's state updated successfully" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["username", "isDeactivate"], + "properties": { + "username": { + "type": "string" + }, + "isDeactivate": { + "type": "boolean" + } + }, + "example": { + "username": "test1", + "is_deactivate": true + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/create_project": { + "post": { + "description": "This API is used to create a project", + "operationId": "createProject", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": { + "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "Name": "my project", + "Members": [ + { + "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b", + "Role": "Owner", + "Invitation": "Accepted", + "JoinedAt": "1640676874" + } + ], + "State": "active", + "CreatedAt": "1627040799", + "UpdatedAt": "1627040799", + "RemovedAt": "" + } + } + }, + "schema": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/Project" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["projectName"], + "properties": { + "projectName": { + "type": "string" + } + }, + "example": { + "projectName": "my project" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/get_project/{project_id}": { + "get": { + "description": "This API is used to get details of a project with given project ID", + "operationId": "getProject", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": { + "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "Name": "my project", + "Members": [ + { + "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b", + "UserName": "admin", + "Name": "", + "Role": "Owner", + "Email": "", + "Invitation": "Accepted", + "JoinedAt": "1640676874", + "DeactivatedAt": "" + } + ], + "State": "active", + "CreatedAt": "1627040799", + "UpdatedAt": "1627040799", + "RemovedAt": "" + } + } + }, + "schema": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/Project" + } + } + } + } + }, + "parameters": [ + { + "name": "project_id", + "required": true, + "description": "ID of the project", + "in": "path", + "type": "string" + } + ], + "produces": ["application/json"] + } + }, + "/get_user_with_project/{username}": { + "get": { + "description": "This API is used to get details of a project for a user\n", + "operationId": "getUserWithProject", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": { + "ID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b", + "UserName": "admin", + "CreatedAt": "1627040799", + "Email": "", + "Name": "", + "Projects": [ + { + "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "Name": "my project", + "Members": [ + { + "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b", + "Role": "Owner", + "Invitation": "Accepted", + "JoinedAt": "1640676874" + } + ], + "State": "active", + "CreatedAt": "1627040799", + "UpdatedAt": "1627040799", + "RemovedAt": "" + } + ] + } + } + }, + "schema": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/GetUserWithProject" + } + } + } + } + }, + "parameters": [ + { + "name": "username", + "required": true, + "description": "username of the user", + "in": "path", + "type": "string" + } + ], + "produces": ["application/json"] + } + }, + "/list_projects": { + "get": { + "description": "This API is used to get project details of logged in user\n", + "operationId": "listProjects", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": [ + { + "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "Name": "my project", + "Members": [ + { + "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b", + "Role": "Owner", + "Invitation": "Accepted", + "JoinedAt": "1640676874" + } + ], + "State": "active", + "CreatedAt": "1627040799", + "UpdatedAt": "1627040799", + "RemovedAt": "" + } + ] + } + }, + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/Project" + } + } + } + } + } + }, + "parameters": [], + "produces": ["application/json"] + } + }, + "/get_projects_stats": { + "get": { + "description": "This API is used to get overall stats for all the projects(accessible only to admin).", + "operationId": "getProjectStats", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": [ + { + "Name": "admin's project", + "ProjectId": "430baca1-cdea-4886-bd80-9cfa204ea81f", + "Members": { + "Owner": [ + { + "UserId": "6abec0cf-7263-4519-bd69-7e02e26837fa", + "Username": "admin" + } + ], + "Total": 2 + } + } + ] + } + }, + "schema": { + "type": "object" + } + } + }, + "parameters": [], + "produces": ["application/json"] + } + }, + "/update_project_name": { + "post": { + "description": "This API is used to update a project name", + "operationId": "updateProjectName", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "Successful" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["projectID", "projectName"], + "properties": { + "projectID": { + "type": "string" + }, + "projectName": { + "type": "string" + } + }, + "example": { + "projectID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "projectName": "admin's project" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/send_invitation": { + "post": { + "description": "This API is used to send project invite to an user", + "operationId": "sendInvitation", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": { + "UserID": "3bdc0bd9-fc46-433b-ac21-05d555566c46", + "UserName": "john", + "Name": "", + "Role": "Viewer", + "Email": "", + "Invitation": "Pending", + "JoinedAt": "1640676874", + "DeactivatedAt": "" + } + } + }, + "schema": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/ProjectMember" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["projectID", "userID", "role"], + "properties": { + "projectID": { + "type": "string" + }, + "userID": { + "type": "string" + }, + "role": { + "type": "string", + "enum": ["Owner", "Editor", "Viewer"] + } + }, + "example": { + "projectID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "userID": "3bdc0bd9-fc46-433b-ac21-05d555566c46", + "role": "Viewer" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/accept_invitation": { + "post": { + "description": "This API is used to accept a project invite", + "operationId": "acceptInvitation", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "Successful" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["projectID", "userID"], + "properties": { + "projectID": { + "type": "string" + }, + "userID": { + "type": "string" + } + }, + "example": { + "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/decline_invitation": { + "post": { + "description": "This API is used to decline a project invite", + "operationId": "declineInvitation", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "Successful" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["projectID", "userID"], + "properties": { + "projectID": { + "type": "string" + }, + "userID": { + "type": "string" + } + }, + "example": { + "projectID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "userID": "3bdc0bd9-fc46-433b-ac21-05d555566c46" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/remove_invitation": { + "post": { + "description": "This API is used to revoke a project invite or remove a project member", + "operationId": "removeInvitation", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "Successful" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": ["projectID", "userID"], + "properties": { + "projectID": { + "type": "string" + }, + "userID": { + "type": "string" + } + }, + "example": { + "projectID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "userID": "3bdc0bd9-fc46-433b-ac21-05d555566c46" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/leave_project": { + "post": { + "description": "This API is used to leave a project", + "operationId": "leaveProject", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "message": "Successful" + } + }, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "required": ["projectID", "userID"], + "projectID": { + "type": "string" + }, + "userID": { + "type": "string" + } + }, + "example": { + "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8", + "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46" + } + } + } + ], + "consumes": ["application/json"], + "produces": ["application/json"] + } + }, + "/get_owner_projects": { + "get": { + "description": "This API is used to list all the project IDs in which the user is the owner\n", + "operationId": "getOwnerProjects", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": ["0ecf9907-238d-4000-ac2f-3dbe38bc8e64"] + } + }, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "parameters": [], + "produces": ["application/json"] + } + }, + "/get_project_role/{project_id}": { + "get": { + "description": "This API is used to fetch the role of the user in the given project\n", + "operationId": "getProjectRole", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "role": "Owner" + } + }, + "schema": { + "type": "object", + "properties": { + "role": { + "type": "string" + } + } + } + } + }, + "parameters": [ + { + "name": "project_id", + "required": true, + "description": "ID of the project", + "in": "path", + "type": "string" + } + ], + "produces": ["application/json"] + } + }, + "/get_project_members/{project_id}/{state}": { + "get": { + "description": "This API is used to fetch members of the project based on the invitation state", + "operationId": "getProjectMembers", + "responses": { + "200": { + "description": "OK", + "examples": { + "application/json": { + "data": [ + { + "userID": "4ded0007-ab3c-4376-9605-14654559ff6c", + "username": "admin", + "email": "admin@gmail.com", + "name": "admin", + "role": "Owner", + "invitation": "Accepted", + "joinedAt": 1690264328 + }, + { + "userID": "345d0007-ab3c-4376-9605-347y3949ff6c", + "username": "john", + "email": "john@gmail.com", + "name": "john doe", + "role": "Editor", + "invitation": "Accepted", + "joinedAt": 1690245328 + } + ] + } + }, + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/ProjectMember" + } + } + } + } + } + }, + "parameters": [ + { + "name": "project_id", + "required": true, + "description": "ID of the project", + "in": "path", + "type": "string" + }, + { + "name": "state", + "required": true, + "description": "state of the invitation", + "in": "path", + "type": "string", + "enum": ["accepted", "not_accepted", "all"] + } + ], + "produces": ["application/json"] + } + }, + "/invite_users/{project_id}": { + "get": { + "description": "This API is used to fetch users who can be invited", + "operationId": "getUsersForInvitation", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + } + } + } + }, + "parameters": [ + { + "name": "project_id", + "required": true, + "description": "ID of the project", + "in": "path", + "type": "string" + } + ], + "produces": ["application/json"] + } + } + }, + "definitions": { + "ErrorModel": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "error": { + "type": "string" + }, + "errorDescription": { + "type": "string" + } + } + }, + "LoginResponse": { + "type": "object", + "properties": { + "accessToken": { + "type": "string" + }, + "expiresIn": { + "type": "integer" + }, + "projectID": { + "type": "string" + }, + "projectRole": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "ActionBy": { + "type": "object", + "properties": { + "userID": { + "type": "string" + }, + "username": { + "type": "string" + }, + "email": { + "type": "string" + } + } + }, + "User": { + "type": "object", + "properties": { + "userID": { + "type": "string" + }, + "username": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string" + }, + "role": { + "type": "string" + }, + "isRemoved": { + "type": "boolean" + }, + "updatedBy": { + "$ref": "#/definitions/ActionBy" + }, + "createdBy": { + "$ref": "#/definitions/ActionBy" + }, + "createAt": { + "type": "integer" + }, + "updatedAt": { + "type": "integer" + } + } + }, + "Users": { + "type": "array", + "items": { + "$ref": "#/definitions/Users" + } + }, + "ProjectMember": { + "type": "object", + "properties": { + "userID": { + "type": "string" + }, + "username": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string" + }, + "role": { + "type": "string", + "enum": ["Owner", "Editor", "Viewer"] + }, + "invitation": { + "type": "string", + "enum": ["Accepted", "Pending", "Declined", "Exited"] + }, + "joinedAt": { + "type": "string" + } + } + }, + "Project": { + "type": "object", + "properties": { + "updatedBy": { + "$ref": "#/definitions/ActionBy" + }, + "createdBy": { + "$ref": "#/definitions/ActionBy" + }, + "createAt": { + "type": "integer" + }, + "updatedAt": { + "type": "integer" + }, + "isRemoved": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "projectID": { + "type": "string" + }, + "state": { + "type": "string" + }, + "members": { + "type": "array", + "items": { + "$ref": "#/definitions/ProjectMember" + } + } + } + }, + "GetUserWithProject": { + "allOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "object", + "properties": { + "Projects": { + "type": "array", + "items": { + "$ref": "#/definitions/Project" + } + } + } + } + ] + } + } +}