openapi: 3.0.0 info: title: API of Disciplines and Plannings version: 1.0.0 description: Documentation for API of Disciplines and Plannings tags: - name: User routes description: Endpoints related to users - name: Login routes description: Endpoints related to login - name: Discipline routes description: Endpoints related to disciplines - name: Planning routes description: Endpoints related to planning components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: UserInterface: type: object required: - role - name - email properties: id: type: integer example: 0 role: type: string enum: [ADMINISTRATOR, COMMON] example: COMMON name: type: string example: User0 email: type: string example: user0@example.com LoginInterface: type: object required: - email - password properties: id: type: integer example: 0 email: type: string example: user0@example.com password: type: string example: password0 DisciplineInterface: type: object required: - name - type - acronym - available - description properties: id: type: integer example: 0 name: type: string example: Discipline0 type: type: string enum: [OBRIGATORY, OPTATIVE] example: OBRIGATORY acronym: type: string example: DISC0 available: type: boolean example: true description: type: string example: Discipline0 description pre_requisites: type: array items: type: string example: D-1 post_requisites: type: array items: type: string example: D1 professor: type: string example: Professor0 schedule: type: string example: Schedule0 PlanningInterface: type: object required: - name - periods properties: id: type: integer description: Unique planning ID example: 0 name: type: string description: Planning's name example: Planning0 periods: type: array description: List of periods associated with the planning items: $ref: '#/components/schemas/PeriodInterface' PeriodInterface: type: object required: - name - planningId - disciplines properties: id: type: integer description: Unique period ID example: 0 name: type: string description: Period's name example: Period0 planningId: type: integer description: Planning's ID to which the period belongs example: 0 disciplines: type: array description: List of disciplines for the period items: $ref: '#/components/schemas/DisciplineInterface' paths: # User routes /users: post: summary: Create a new user tags: - User routes requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UserInterface' responses: 201: description: Create a new user content: application/json: schema: type: object properties: message: type: string example: "User '${ name }' was created successfully!" user: $ref: '#/components/schemas/UserInterface' 409: description: Try to create a new user who already exists content: application/json: schema: type: object properties: message: type: string example: "User already exists!" 400: description: Try create a new user with empty or invalid fields content: application/json: schema: type: object properties: message: type: string example: "User's ${property.name} is required!" /users/{id}: delete: summary: Delete one user tags: - User routes parameters: - in: path name: id required: true schema: type: integer responses: 200: description: User was deleted successfully content: application/json: schema: type: object properties: message: type: string example: "User was deleted successfully!" 404: description: Try to delete a user that does not exist content: application/json: schema: type: object properties: message: type: string example: "User not found!" /protected/users: delete: summary: Delete all users tags: - User routes security: - BearerAuth: [] responses: 200: description: Delete all users content: application/json: schema: type: object properties: message: type: string example: "All users were deleted successfully!" 403: description: Try to delete all users without authentication content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 404: description: Try to delete all users when there are no users content: application/json: schema: type: object properties: message: type: string example: "No users found!" get: summary: Returns a list of all users parameters: - in: query name: page schema: type: integer default: 1 description: Page number for pagination - in: query name: limit schema: type: integer default: 10 description: Number of users per page tags: - User routes security: - BearerAuth: [] responses: 200: description: All users were returned successfully content: application/json: schema: type: object properties: message: type: string example: "Users were found successfully!" users: type: array items: $ref: '#/components/schemas/UserInterface' 403: description: Try to get all users without authentication content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 404: description: Try to get all users when there are no users content: application/json: schema: type: object properties: message: type: string example: "No users found!" /protected/users/getByID/{id}: get: summary: Returns a user by its ID tags: - User routes security: - BearerAuth: [] parameters: - in: path name: id required: true schema: type: integer responses: 200: description: User was found successfully content: application/json: schema: type: object properties: message: type: string example: "User was found successfully!" user: $ref: '#/components/schemas/UserInterface' 403: description: Try to get user by ID without authentication content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 400: description: Try to get a user by its ID when the ID is not a number content: application/json: schema: type: object properties: message: type: string example: "User ID must be a number!" 404: description: Try to get a user by its id that does not exist content: application/json: schema: type: object properties: message: type: string example: "User not found!" /protected/users/getByEmail/{email}: get: summary: Returns a user by its email tags: - User routes security: - BearerAuth: [] parameters: - in: path name: email required: true schema: type: string responses: 200: description: User was found successfully content: application/json: schema: type: object properties: message: type: string example: "User was found successfully!" user: $ref: '#/components/schemas/UserInterface' 400: description: Try to get a user by its email when the email is invalid content: application/json: schema: type: object properties: message: type: string example: "This email '${ userEmail }' is invalid, should be like 'name@example.com'!" 403: description: Try to get a user by its email without authentication content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 404: description: Try to get a user by its id that does not exist content: application/json: schema: type: object properties: message: type: string example: "User with email '${ userEmail }' not found!" /protected/users/getByRole/{role}: get: summary: Returns a user by its role tags: - User routes security: - BearerAuth: [] parameters: - in: path name: role required: true schema: type: string enum: [ADMINISTRATOR, COMMON] responses: 200: description: User was found successfully content: application/json: schema: type: object properties: message: type: string example: "User was found successfully!" user: $ref: '#/components/schemas/UserInterface' 403: description: Try to get a user by its role without authentication content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 400: description: Try to get a user by its role when the role is invalid content: application/json: schema: type: object properties: message: type: string example: "The role must be either ADMINISTRATOR or COMMON!" 404: description: Try to get a user by its role that does not exist content: application/json: schema: type: object properties: message: type: string example: "No users with '${ userRole }' role found!" # Login routes /auth/login: post: summary: Create a new login tags: - Login routes requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LoginInterface' responses: 201: description: Create a new login content: application/json: schema: type: object properties: message: type: string example: "User '${ name }' was created successfully!" user: $ref: '#/components/schemas/LoginInterface' 409: description: Try to create a new login who already exists content: application/json: schema: type: object properties: message: type: string example: "User already have a login!" 400: description: Try create a login with invalid data content: application/json: schema: type: object properties: message: type: string example: "User's ${property.name} is required!" /login/getTokenByUserEmail: post: summary: Returns a token for a user tags: - Login routes requestBody: required: true content: application/json: schema: type: object required: - email - password properties: email: type: string example: user0@example.com password: type: string example: password0 responses: 201: description: Returns a token for a user content: application/json: schema: type: object properties: message: type: string example: "User '${ name }' was created successfully!" user: $ref: '#/components/schemas/LoginInterface' 404: description: Try to get a token for a user who does not have a login content: application/json: schema: type: object properties: message: type: string example: "User don't have a login!" 400: description: Try get a token for a user with invalid data content: application/json: schema: type: object properties: message: type: string example: "User's ${property.name} is required!" # Discipline routes /protected/disciplines: post: summary: Create a new discipline tags: - Discipline routes security: - BearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DisciplineInterface' responses: 201: description: Create a new discipline content: application/json: schema: type: object properties: message: type: string example: "Discipline created successfully!" discipline: $ref: '#/components/schemas/DisciplineInterface' 403: description: Try to create a discipline without a valid token content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 409: description: Try to create a new discipline who already exists content: application/json: schema: type: object properties: message: type: string example: "Discipline already exists!" 400: description: Try create a new discipline with empty fields content: application/json: schema: type: object properties: message: type: string example: "Discipline's ${property.name} cannot be empty!" delete: summary: Delete all disciplines tags: - Discipline routes security: - BearerAuth: [] responses: 200: description: Delete all disciplines content: application/json: schema: type: object properties: message: type: string example: "All disciplines were deleted successfully!" 403: description: Try to delete all disciplines without authentication content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 404: description: Try to delete all disciplines when there are no disciplines content: application/json: schema: type: object properties: message: type: string example: "No disciplines found!" /disciplines: get: summary: Returns a list of all disciplines tags: - Discipline routes parameters: - in: query name: page schema: type: integer default: 1 description: Page number for pagination - in: query name: limit schema: type: integer default: 10 description: Number of disciplines per page responses: 200: description: All disciplines were returned successfully content: application/json: schema: type: object properties: message: type: string example: "Disciplines were found successfully!" disciplines: type: array items: $ref: '#/components/schemas/DisciplineInterface' 404: description: Try to get all disciplines when there are no disciplines content: application/json: schema: type: object properties: message: type: string example: "No disciplines found!" /disciplines/getByID/{id}: get: summary: Returns a discipline by its ID tags: - Discipline routes parameters: - in: path name: id required: true schema: type: integer responses: 200: description: Discipline was found successfully content: application/json: schema: type: object properties: message: type: string example: "Discipline was found successfully!" discipline: $ref: '#/components/schemas/DisciplineInterface' 404: description: Try to get a discipline by its id that does not exist content: application/json: schema: type: object properties: message: type: string example: "Discipline not found!" /disciplines/getByAcronym/{acronym}: get: summary: Returns a discipline by its acronym tags: - Discipline routes parameters: - in: path name: acronym required: true schema: type: string responses: 200: description: Discipline was found successfully content: application/json: schema: type: object properties: message: type: string example: "Discipline was found successfully!" discipline: $ref: '#/components/schemas/DisciplineInterface' 404: description: Try to get a discipline by its id that does not exist content: application/json: schema: type: object properties: message: type: string example: "Discipline not found!" /disciplines/getByName/{name}: get: summary: Returns a discipline by its name tags: - Discipline routes parameters: - in: path name: name required: true schema: type: string responses: 200: description: Discipline was found successfully content: application/json: schema: type: object properties: message: type: string example: "Discipline was found successfully!" discipline: $ref: '#/components/schemas/DisciplineInterface' 404: description: Try to get a discipline by its name that does not exist content: application/json: schema: type: object properties: message: type: string example: "Discipline not found!" /protected/disciplines/{id}: patch: summary: Update discipline's field tags: - Discipline routes security: - BearerAuth: [] parameters: - in: path name: id required: true description: Discipline's ID schema: type: integer requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DisciplineInterface' responses: 200: description: Discipline field was updated successfully content: application/json: schema: type: object properties: message: type: string example: "Discipline's field was updated successfully!" discipline: $ref: '#/components/schemas/DisciplineInterface' 403: description: Try to update a discipline field without being authenticated content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 404: description: Try to update a discipline that does not exist content: application/json: schema: type: object properties: message: type: string example: "Discipline not found!" delete: summary: Delete a discipline tags: - Discipline routes security: - BearerAuth: [] parameters: - in: path name: id required: true description: Discipline's ID schema: type: integer responses: 200: description: Discipline was deleted successfully content: application/json: schema: type: object properties: message: type: string example: "Discipline was deleted successfully!" 403: description: Try to delete a discipline without being authenticated content: application/json: schema: type: object properties: message: type: string example: "Access denied: invalid token!" 404: description: Try to delete a discipline that does not exist content: application/json: schema: type: object properties: message: type: string example: "Discipline not found!" # Planning routes /planning: post: summary: Create a new plan tags: - Planning routes requestBody: required: true content: application/json: schema: type: object properties: name: type: string description: The name of the planning userId: type: integer description: The ID of the user who created the planning periods: type: array description: List of periods associated with planning items: type: object properties: name: type: string description: Period name disciplines: type: array description: List of subjects associated with the period items: type: integer required: - name - periods responses: 201: description: Planning created successfully content: application/json: schema: type: object properties: message: type: string example: "Planning created!" createdPlanning: $ref: '#/components/schemas/PlanningInterface' 400: description: Erro nos dados fornecidos 409: description: Planejamento já existente com o nome fornecido 500: description: Erro interno do servidor put: summary: Updates an existing planning, but needs the planning ID and also the ID of each period (frontend will have access through get) tags: - Planning routes requestBody: required: true content: application/json: schema: type: object properties: id: type: integer description: Planning's ID name: type: string description: Planning's name periods: type: array description: List of periods associated with planning items: type: object properties: id: type: integer description: Period's ID name: type: string description: Period's name disciplines: type: array description: List of disciplines associated with the period items: type: integer required: - id - name - periods responses: 200: description: Planning updated successfully content: application/json: schema: type: object properties: message: type: string example: "Planning updated!" updatedPlanning: $ref: '#/components/schemas/PlanningInterface' 400: description: Error in the data provided 404: description: Planning not found 500: description: Internal server error get: summary: Returns all plans tags: - Planning routes responses: 200: description: Planning list returned successfully content: application/json: schema: type: object properties: message: type: string example: "Plannings fetched" planning: type: array items: $ref: '#/components/schemas/PlanningInterface' /planning/{id}: get: summary: Returns a specific planning by ID tags: - Planning routes parameters: - in: path name: id required: true description: Planning's ID schema: type: integer responses: 200: description: Planning found successful content: application/json: schema: type: object properties: message: type: string example: "Planning fetched" planning: $ref: '#/components/schemas/PlanningInterface' 404: description: Planning not found 500: description: Internal server error