{ "openapi": "3.0.0", "info": { "title": "API Cantina Documentation", "description": "Essa é a documentação para a API Cantina", "version": "1.0.0", "contact": { "email": "nalissongm.pro@gmail.com" } }, "servers":[ { "url": "http://localhost:3333/api/", "description": "Servidor de testes" }, { "url": "http://200.17.32.148:3333/api/", "description": "Servidor de produção" } ], "paths": { "/sessions": { "post": { "summary": "Autenticar usuário", "description": "Autentica um usuário e retorna um token de acesso JWT que deve ser passado no cabeçalho das as requisições que necessitam de autentificação. O token tem validade de 30 minutos e deve ser renovado com o refresh token.", "tags": ["Autenticação"], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "matricula": { "type": "string" }, "email": { "type": "string" }, "password": { "type": "string" } }, "required": ["password"] }, "examples": { "aluno - email": { "value": { "email": "joao@gmail.com", "password": "JL.78945" } }, "aluno - matricula": { "value": { "matricula": "20242078945", "password": "JL.78945" } }, "servidor e funcionario": { "value": { "email": "paulo@gmail.com", "password": "admin123" } } } } } }, "responses": { "400": { "description": "Matricula, email ou senha inválidos" }, "200": { "description": "Ok", "content": { "application/json": { "schema": { "type": "object", "properties": { "user": { "type": "object", "properties": { "token": { "type": "string" }, "user": { "type": "object", "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "type": { "type": "string" }, "cpf": { "type": "string" } } }, "refreshToken": { "type": "string" } } } } }, "examples": { "Aluno com email": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "email": "joao@gmail.com", "type": "aluno" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } }, "Aluno sem email": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "type": "aluno" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } }, "Servidor": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "email": "paulo@gmail.com", "type": "servidor" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } }, "Funcionario": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "email": "carlos@gmail.com", "type": "funcionario" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } } } } } } } } }, "/refresh-token": { "post": { "summary": "Renovar Token", "description": "Recebe o refresh token pelo header, body ou query e renova o token de acesso retornando um novo token e um novo refresh token. O Refresh Token tem validade de 7 dias.", "tags": ["Autenticação"], "parameters": [ { "in": "header", "name": "x-access-token", "description": "Refresh Token via Cabeçalho", "required": false, "schema": { "type": "string" } }, { "in": "query", "name": "token", "description": "Refresh Token via Query", "required": false, "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string" } } }, "examples": { "Token via Body": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c" } } } } } }, "responses": { "400": { "description": "Refresh Token expirado, inválido ou ausente" }, "401": { "description": "Assinatura inválida" }, "404": { "description": "Refresh Token não encontrado ou não existe" }, "200": { "description": "Ok", "content": { "application/json": { "schema": { "type": "object", "properties": { "user": { "type": "object", "properties": { "token": { "type": "string" }, "user": { "type": "object", "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "type": { "type": "string" }, "cpf": { "type": "string" } } }, "refreshToken": { "type": "string" } } } } }, "examples": { "Aluno com email": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "email": "joao@gmail.com", "type": "aluno" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } }, "Aluno sem email": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "type": "aluno" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } }, "Servidor": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "email": "paulo@gmail.com", "type": "servidor" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } }, "Funcionario": { "value": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE2NjAzODUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.gvxM_t1BbPhy3rEasQf_BHL2CeRyyeCGwlJXHeLCv_c", "user": { "id": "0ede456c-191e-4568-953d-5c0c47d54db8", "email": "carlos@gmail.com", "type": "funcionario" }, "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImVtYWlsIjoic2Vydmlzb3IuYWRtaW5AZW1haWwuY29tIiwidHlwZSI6InNlcnZpZG9yIn0sImlhdCI6MTcxNjYwMDI1MCwiZXhwIjoxNzE5MTkyMjUwLCJzdWIiOiIwZWRlNDU2Yy0xOTFlLTQ1NjgtOTUzZC01YzBjNDdkNTRkYjgifQ.NzNLmIut-f8FIHrBQ5JWRKHubs92AB7I9oXLy4STGNM" } } } } } } } } }, "/accounts/alunos": { "post": { "summary": "Criar um aluno", "description": "Rota para criar um novo aluno", "tags": ["Alunos"], "security": [ {"bearerAuth": []} ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Aluno" }, "examples": { "aluno": { "value": { "cpf": "01234567890", "nome": "Carlos Serafim", "sexo": "M", "cidade": "Iguatu-CE", "userId": "54764e0e-3b9e-434d-a8ff-61ad920b25da", "matriculas": [ { "matricula": "3333333333", "situacao": "matriculado", "turno": "integrado", "cursoId": "3231819e-c237-4d19-a55a-15cdee38b41a", "turmaId": "f725d928-02ee-40f4-b207-276a8dcdf30c" } ] } } } } } }, "responses": { "401": { "$ref": "#/components/responses/UnauthorizedError" }, "400": { "description": "Possíveis erros: parâmetros insuficientes, matrícula pertence a outro aluno, aluno já foi cadastrado, usuário não existe, usuário não é um aluno ou usuário já está associado a outra conta." }, "201":{ "description": "Aluno foi criado com sucesso." } } }, "get": { "summary": "Listar alunos", "description": "Rota para listar todos os alunos cadastrados.", "tags": ["Alunos"], "security": [ {"bearerAuth": []} ], "responses": { "200": { "description": "Ok", "content": { "application/json": { "types": "array", "items": { "schema": { "$ref": "#/components/schemas/Aluno" } }, "example": [ { "cpf": "01234567891", "nome": "Abner Peixeira", "sexo": "M", "cidade": null, "createdAt": "2024-06-20T19:57:32.464Z", "updatedAt": "2024-06-20T19:57:32.464Z", "userId": "73a70cec-98fd-4038-885f-211a07e4bae4", "Matricula": [ { "matricula": "33333387378945", "situacaoMatricula": "matriculado", "turno": "integral", "createdAt": "2024-06-20T19:57:32.472Z", "updatedAt": "2024-06-20T19:57:32.472Z", "alunoCpf": "01234567891", "turmaId": null, "cursoId": null } ] }, { "cpf": "07471215321", "nome": "Carlos Serafim", "sexo": "M", "cidade": "Iguatu-CE", "createdAt": "2024-05-25T01:45:16.981Z", "updatedAt": "2024-05-25T01:45:16.981Z", "userId": "2e732844-5f9f-460e-8522-7f93dd3255c7", "Matricula": [ { "matricula": "123456", "situacaoMatricula": "matriculado", "turno": "integral", "createdAt": "2024-05-25T01:45:16.986Z", "updatedAt": "2024-05-25T01:45:16.986Z", "alunoCpf": "07471215321", "turmaId": null, "cursoId": null }, { "matricula": "888888", "situacaoMatricula": "matriculado", "turno": "integral", "createdAt": "2024-05-25T01:45:16.986Z", "updatedAt": "2024-05-25T01:45:16.986Z", "alunoCpf": "07471215321", "turmaId": null, "cursoId": null } ] } ] } } } } } }, "/accounts/alunos/{cpf}":{ "get": { "summary": "Buscar um aluno", "description": "A rota recebe o CPF nos parâmetros da requisição e retorna os dados do aluno correspondente junto com as suas matrículas. Também é possível definir se o retorno conterá as matrículas ou não através da query 'matriculas'. Por padrão, o retorno contém as matrículas.", "tags": ["Alunos"], "security": [ {"bearerAuth": []} ], "parameters": [ { "name": "cpf", "in": "path", "description": "CPF do aluno", "required": true, "schema": { "type": "string" }, "example": "00011122214" }, { "name": "matriculas", "in": "query", "description": "Recebe 'true' ou 'false' para definir se o retorno conterá as matrículas ou não. 'true' por padrão.", "required": false, "schema": { "type": "boolean" }, "example": true } ], "responses": { "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Aluno não encontrado" }, "200": { "description": "Ok", "content": { "application/json": { "items": { "schema": { "$ref": "#/components/schemas/Aluno" } }, "examples": { "Com matrículas": { "description": "Retorna o aluno com as matrículas.", "value": { "cpf": "07471215321", "nome": "Carlos Serafim", "sexo": "M", "cidade": "Iguatu-CE", "createdAt": "2024-05-25T01:45:16.981Z", "updatedAt": "2024-05-25T01:45:16.981Z", "userId": "2e732844-5f9f-460e-8522-7f93dd3255c7", "Matricula": [ { "matricula": "123456", "situacaoMatricula": "matriculado", "turno": "integral", "createdAt": "2024-05-25T01:45:16.986Z", "updatedAt": "2024-05-25T01:45:16.986Z", "alunoCpf": "07471215321", "turmaId": null, "cursoId": null }, { "matricula": "888888", "situacaoMatricula": "matriculado", "turno": "integral", "createdAt": "2024-05-25T01:45:16.986Z", "updatedAt": "2024-05-25T01:45:16.986Z", "alunoCpf": "07471215321", "turmaId": null, "cursoId": null } ] } }, "Sem matrículas": { "description": "Retorna o aluno sem as matrículas.", "value": { "cpf": "07471215321", "nome": "Carlos Serafim", "sexo": "M", "cidade": "Iguatu-CE", "createdAt": "2024-05-25T01:45:16.981Z", "updatedAt": "2024-05-25T01:45:16.981Z", "userId": "2e732844-5f9f-460e-8522-7f93dd3255c7" } } } } } } } }, "put": { "summary": "Atualizar aluno", "description": "A rota recebe o **CPF** nos parâmetros da requisição e os dados do aluno a serem atualizados no corpo da requisição. É possível alterar o **nome**, o **sexo** e a **cidade**.", "tags": ["Alunos"], "security": [ {"bearerAuth": []} ], "parameters": [ { "name": "CPF", "in": "path", "description": "CPF do aluno", "required": true, "schema": { "type": "string" }, "example": "11122233300" } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "cursoId": { "type": "string" }, "turmaId": { "type": "string" } }, "example": { } }, "example": { "nome": "Carlos Serafim", "cidade": "Iguatu-CE", "sexo": "M" } } } }, "responses": { "404": { "description": "Aluno não encontrado." }, "422": { "description": "Argumentos inválidos." }, "204": { "description": "Os dados foram atualizados com sucesso." } } }, "delete": { "summary": "Delete aluno", "description": "Rota para deleta o aluno pelo **CPF** e todas as suas matrículas.", "tags": ["Alunos"], "security": [ {"bearerAuth": []} ], "parameters": [ { "name": "CPF", "in": "path", "description": "CPF do aluno", "required": true, "schema": { "type": "string" }, "example": "11122233300" } ], "responses": { "404": { "description": "Aluno não encontrado" }, "204": { "description": "Aluno foi deletado com sucesso." } } } }, "/cursos":{ "post": { "summary": "Criar curso", "description": "Rota para criar um novo curso", "tags": ["Cursos"], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Curso" }, "examples": { "Default - Nome [obrigatório]": { "description": "Passando apenas o nome - A API crias as demais", "value":{ "name": "Informática" } }, "Full": { "description": "Passando todas as informações manualmente", "value": { "id": "3231819e-c237-4d19-a55a-15cdee38b41a", "name": "Informática", "createdAt": "2023-07-14T20:42:39.612Z", "updatedAt": "2023-07-14T20:42:39.612Z" } } } } } }, "responses": { "201": { "description": "Criado com sucesso" }, "400": { "description": "Já existe um curso com o mesmo nome" } } }, "get": { "summary": "Listar cursos", "description": "Rota para listar todos os cursos cadastrados", "tags": ["Cursos"], "responses": { "200": { "description": "Ok", "content": { "application/json": { "type": "array", "items": { "schema": { "$ref": "#/components/schemas/Curso" } }, "example": [ { "id": "f725d928-02ee-40f4-b207-276a8dcdf30c", "name": "Informática", "createdAt": "2023-07-14T17:22:24.892Z", "updatedAt": "2023-07-14T19:40:34.745Z" }, { "id": "98452e4a-7503-49d8-a20a-506c4fd48999", "name": "Letras", "createdAt": "2023-07-14T20:42:39.612Z", "updatedAt": "2023-07-14T20:42:39.612Z" } ] } } } } } }, "/cursos/{id}": { "put": { "summary": "Atualizar curso", "description": "Rota para atualizar dados do curso pelo **id**", "tags": ["Cursos"], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" } }, "required": ["name"] } } } }, "parameters": [ { "name": "id", "in": "path", "description": "**ID** do Curso", "required": true, "schema": { "type": "string" }, "example": "98452e4a-7503-49d8-a20a-506c4fd48999" } ], "responses": { "204": { "description": "A Alteração foi efetuada com sucesso" }, "400": { "description": "Já existe um curso com o mesmo nome" }, "404": { "description": "Curso não encontrado" } } }, "get": { "summary": "Buscar curso por ID", "description": "Rota para buscar um curso pelo **ID**", "tags": ["Cursos"], "parameters": [ { "name": "id", "in": "path", "description": "**ID** do Curso", "required": true, "schema": { "type": "string" }, "example": "98452e4a-7503-49d8-a20a-506c4fd48999" } ], "responses": { "404": { "description": "Curso não encontrado" }, "200": { "description": "Ok", "content": { "application/json": { "type": "array", "items": { "schema": { "$ref": "#/components/schemas/Curso" } }, "example":{ "id": "f725d928-02ee-40f4-b207-276a8dcdf30c", "name": "Informática", "createdAt": "2023-07-14T17:22:24.892Z", "updatedAt": "2023-07-14T19:40:34.745Z" } } } } } }, "delete": { "summary": "Deletar curso", "description": "Rota para deletar um curso pelo **ID**", "tags": ["Cursos"], "parameters": [ { "name": "id", "in": "path", "description": "**ID** do Curso", "required": true, "schema": { "type": "string" }, "example": "98452e4a-7503-49d8-a20a-506c4fd48999" } ], "responses": { "204": { "description": "Deletado com sucesso" }, "404": { "description": "Curso não encontrado" } } } }, "/cursos/search": { "get": { "summary": "Procurar por cursos", "description": "Rota para procurar cursos pelo nome", "tags": ["Cursos"], "parameters": [ { "name": "name", "in": "query", "description": "Nome do curso ou dos cursos", "schema": { "type": "string" }, "example": "inf" } ], "responses": { "200": { "description": "Ok", "content": { "application/json": { "type": "array", "items": { "schema": { "$ref": "#/components/schemas/Curso" } }, "example": [ { "id": "f725d928-02ee-40f4-b207-276a8dcdf30c", "name": "Informática", "createdAt": "2023-07-14T17:22:24.892Z", "updatedAt": "2023-07-14T19:40:34.745Z" }, { "id": "98452e4a-7503-49d8-a20a-506c4fd48999", "name": "Letras", "createdAt": "2023-07-14T20:42:39.612Z", "updatedAt": "2023-07-14T20:42:39.612Z" } ] } } } } } }, "/turmas":{ "post": { "summary": "Criar turma", "description": "Rota para criar um novo turma", "tags": ["Turmas"], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Turma" }, "examples": { "Default - Nome [obrigatório]": { "description": "Passando apenas o nome - A API crias as demais", "value":{ "name": "a-01" } }, "Full": { "description": "Passando todas as informações manualmente", "value": { "id": "3231819e-c237-4d19-a55a-15cdee38b41a", "name": "a-1", "createdAt": "2023-07-14T20:42:39.612Z", "updatedAt": "2023-07-14T20:42:39.612Z" } } } } } }, "responses": { "201": { "description": "Criado com sucesso" }, "400": { "description": "Já existe um turma com o mesmo nome" } } }, "get": { "summary": "Listar turmas", "description": "Rota para listar todos os turmas cadastrados", "tags": ["Turmas"], "responses": { "200": { "description": "Ok", "content": { "application/json": { "type": "array", "items": { "schema": { "$ref": "#/components/schemas/Turma" } }, "example": [ { "id": "f725d928-02ee-40f4-b207-276a8dcdf30c", "name": "a-1", "createdAt": "2023-07-14T17:22:24.892Z", "updatedAt": "2023-07-14T19:40:34.745Z" }, { "id": "98452e4a-7503-49d8-a20a-506c4fd48999", "name": "a-04", "createdAt": "2023-07-14T20:42:39.612Z", "updatedAt": "2023-07-14T20:42:39.612Z" } ] } } } } } }, "/turmas/{id}": { "put": { "summary": "Atualizar turma", "description": "Rota para atualizar dados do turma pelo **id**", "tags": ["Turmas"], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" } }, "required": ["name"] } } } }, "parameters": [ { "name": "id", "in": "path", "description": "**ID** do Turma", "required": true, "schema": { "type": "string" }, "example": "98452e4a-7503-49d8-a20a-506c4fd48999" } ], "responses": { "204": { "description": "A Alteração foi efetuada com sucesso" }, "400": { "description": "Já existe um turma com o mesmo nome" }, "404": { "description": "Turma não encontrado" } } }, "get": { "summary": "Buscar turma por ID", "description": "Rota para buscar um turma pelo **ID**", "tags": ["Turmas"], "parameters": [ { "name": "id", "in": "path", "description": "**ID** do Turma", "required": true, "schema": { "type": "string" }, "example": "98452e4a-7503-49d8-a20a-506c4fd48999" } ], "responses": { "404": { "description": "Turma não encontrado" }, "200": { "description": "Ok", "content": { "application/json": { "type": "array", "items": { "schema": { "$ref": "#/components/schemas/Turma" } }, "example":{ "id": "f725d928-02ee-40f4-b207-276a8dcdf30c", "name": "a-1", "createdAt": "2023-07-14T17:22:24.892Z", "updatedAt": "2023-07-14T19:40:34.745Z" } } } } } }, "delete": { "summary": "Deletar turma", "description": "Rota para deletar um turma pelo **ID**", "tags": ["Turmas"], "parameters": [ { "name": "id", "in": "path", "description": "**ID** do Turma", "required": true, "schema": { "type": "string" }, "example": "98452e4a-7503-49d8-a20a-506c4fd48999" } ], "responses": { "204": { "description": "Deletado com sucesso" }, "404": { "description": "Turma não encontrado" } } } }, "/turmas/search": { "get": { "summary": "Procurar por turmas", "description": "Rota para procurar turmas pelo nome", "tags": ["Turmas"], "parameters": [ { "name": "name", "in": "query", "description": "Nome da turma ou das turmas", "schema": { "type": "string" }, "example": "a" } ], "responses": { "200": { "description": "Ok", "content": { "application/json": { "type": "array", "items": { "schema": { "$ref": "#/components/schemas/Turma" } }, "example": [ { "id": "f725d928-02ee-40f4-b207-276a8dcdf30c", "name": "a-1", "createdAt": "2023-07-14T17:22:24.892Z", "updatedAt": "2023-07-14T19:40:34.745Z" }, { "id": "98452e4a-7503-49d8-a20a-506c4fd48999", "name": "a-4", "createdAt": "2023-07-14T20:42:39.612Z", "updatedAt": "2023-07-14T20:42:39.612Z" } ] } } } } } } }, "components": { "schemas": { "Aluno": { "type": "object", "properties": { "cpf": { "type": "string" }, "nome": { "type": "string" }, "sexo": { "type": "string" }, "cidade": { "type": "string" }, "userId": { "type": "string" }, "matriculas": { "type": "array", "items": { "$ref": "#/components/schemas/Matrícula" } } }, "required": ["cpf", "nome", "sexo", "userId", "matriculas"] }, "Matrícula": { "type": "object", "properties": { "matricula": { "type": "string" }, "situacao": { "type": "string" }, "turno": { "type": "string" }, "alunoCpf": { "type": "string" }, "cursoId": { "type": "string" }, "turmaId": { "type": "string" } }, "required": ["matricula"] }, "Curso": { "type": "object", "properties": { "name": { "type": "string" }, "id": { "type": "string" }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" } }, "required": ["name"] }, "Turma": { "type": "object", "properties": { "name": { "type": "string" }, "id": { "type": "string" }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" } }, "required": ["name"] } }, "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }, "responses": { "UnauthorizedError": { "description": "Usuário não autorizado" } } } }