diff --git a/openapi/features/auth/components/login-request-body.yaml b/openapi/features/auth/components/login-request-body.yaml new file mode 100644 index 0000000..f566dbe --- /dev/null +++ b/openapi/features/auth/components/login-request-body.yaml @@ -0,0 +1,17 @@ +required: true +content: + application/json: + schema: + type: object + properties: + username: + type: string + description: The username for login + example: 'johndoe123' + password: + type: string + description: The password for login + example: '001@Mypassword' + required: + - username + - password diff --git a/openapi/features/auth/components/login-response-body.yaml b/openapi/features/auth/components/login-response-body.yaml new file mode 100644 index 0000000..7f7eea5 --- /dev/null +++ b/openapi/features/auth/components/login-response-body.yaml @@ -0,0 +1,18 @@ +description: User successfully authenticated +content: + application/json: + schema: + type: object + properties: + token: + type: string + description: User Access Token + example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' + issuedAt: + type: string + description: Timestamp that indicates the time at which the token was issued + example: '1714233677' + expireAt: + type: string + description: Token expiration time + example: '1714237277' diff --git a/openapi/features/auth/errors/unauthorized-error.yaml b/openapi/features/auth/errors/unauthorized-error.yaml new file mode 100644 index 0000000..947fc54 --- /dev/null +++ b/openapi/features/auth/errors/unauthorized-error.yaml @@ -0,0 +1,12 @@ +description: Unable to authenticate user +content: + application/json: + schema: + type: object + properties: + code: + type: number + example: 401 + message: + type: string + example: Not authenticated diff --git a/openapi/features/auth/login-path.yaml b/openapi/features/auth/login-path.yaml new file mode 100644 index 0000000..56df4ff --- /dev/null +++ b/openapi/features/auth/login-path.yaml @@ -0,0 +1,18 @@ +post: + summary: User login for system authentication + description: This endpoint allows the user to authenticate into the application. + tags: + - user + + requestBody: + $ref: './components/user-login-body.yaml' + + responses: + '200': + $ref: './components/login-response-body.yaml' + '400': + $ref: '../../shared/errors/validation-error.yaml' + '401': + $ref: './errors/unauthorized-error.yaml' + '500': + $ref: '../../shared/errors/server-error.yaml' diff --git a/openapi/main.yaml b/openapi/main.yaml index 7f34648..72de1ca 100644 --- a/openapi/main.yaml +++ b/openapi/main.yaml @@ -13,3 +13,5 @@ tags: paths: /api/users: $ref: './features/user/user-create-path.yaml' + /auth/login: + $ref: './features/auth/login-path.yaml'