openapi: 3.0.3 info: title: API Liven description: |- Desenvolvida uma API HTTP com cadastro e controle de usuários. version: 1.0.0 servers: - url: http://localhost:8000/api/v1 tags: - name: user description: Ações relacionadas ao usuário paths: /user: post: tags: - user summary: Cadastra um usuário description: Cadastra um novo usuário. requestBody: content: application/json: schema: $ref: '#/components/schemas/User' responses: '201': description: Created content: application/json: schema: properties: message: type: string example: Usuário criado com sucesso! user: type: object properties: name: type: string email: type: string updated_at: type: string format: date-time created_at: type: string format: date-time id: type: integer '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao criar o usuário! /user/login: post: tags: - user summary: Realiza o login do usuário description: Realiza o login com o retorno do token para autenticação. requestBody: content: application/json: schema: $ref: '#/components/schemas/Login-User' responses: '200': description: OK content: application/json: schema: properties: user: type: object properties: id: type: integer name: type: string email: type: string created_at: type: string format: date-time updated_at: type: string format: date-time Authorization: type: object properties: token: type: string example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... type: type: string example: Bearer expires_in: type: integer example: 10800 '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao realizar o login! /user/refresh: post: tags: - user description: Atualiza o token do usuário. responses: '200': description: OK content: application/json: schema: properties: user: type: object properties: id: type: integer name: type: string email: type: string created_at: type: string format: date-time updated_at: type: string format: date-time Authorization: type: object properties: token: type: string example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... type: type: string example: Bearer expires_in: type: integer example: 10800 '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '409': description: Conflict content: application/json: schema: properties: errors: type: string example: Erro ao atualizar o token! security: - bearerAuth: [] /user/me: get: tags: - user description: Retorna os dados do usuário logado responses: '200': description: OK content: application/json: schema: properties: data: type: object properties: id: type: integer name: type: string email: type: string created_at: type: string format: date-time updated_at: type: string format: date-time addresses: type: array items: properties: id: type: integer street: type: string number: type: string neighborhood: type: string additional: type: string city: type: string state: type: string country: type: string postal_code: type: string created_at: type: string format: date-time updated_at: type: string format: date-time '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao encontrar o usuário! security: - bearerAuth: [] /user/{id}: put: tags: - user summary: Edita o endereço description: Edita os dados dos usuários logados. parameters: - name: id in: path required: true description: Insira o id do usuário que você deseja alterar as informações schema: type: integer requestBody: content: application/json: schema: $ref: '#/components/schemas/Update-User' responses: '200': description: OK content: application/json: schema: properties: message: type: string example: Usuário editado com sucesso! user: type: object properties: id: type: integer name: type: string email: type: string created_at: type: string format: date-time updated_at: type: string format: date-time '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao criar o usuário! security: - bearerAuth: [] delete: tags: - user summary: Deleta o usuário description: Deleta o usuário utilizando o id parameters: - name: id in: path required: true description: Insira o id do usuário que você deseja deletar as informações schema: type: integer responses: '200': description: OK content: application/json: schema: properties: data: type: string example: Usuário deletado com sucesso! '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao deletar o usuário! security: - bearerAuth: [] /user/logout: post: tags: - user description: Realiza o logout do usuário. responses: '200': description: OK content: application/json: schema: properties: message: type: string example: Usuário deslogado com sucesso! '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente security: - bearerAuth: [] /user/address: post: tags: - address summary: Cadastra um novo endereço description: Cadastra um novo endereço relacionado ao usuário autenticado. requestBody: content: application/json: schema: $ref: '#/components/schemas/Address' responses: '201': description: Created content: application/json: schema: properties: message: type: string example: Endereço criado com sucesso! address: type: object properties: id: type: integer street: type: string number: type: string neighborhood: type: string additional: type: string city: type: string state: type: string country: type: string postal_code: type: string created_at: type: string format: date-time updated_at: type: string format: date-time '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao criar o endereço! security: - bearerAuth: [] get: tags: - address summary: Retorna os endereços do usuário description: Retorna os endereços relacionados ao usuário autenticado com filtros. parameters: - name: street in: query description: Rua do endereço required: false schema: type: string - name: number in: query description: Número do endereço required: false schema: type: string - name: neighborhood in: query description: Bairro do endereço required: false schema: type: string - name: additional in: query description: Complemento do endereço required: false example: Apt. 45 schema: type: string - name: city in: query description: Cidade do endereço required: false schema: type: string - name: state in: query description: Sigla do estado do endereço required: false example: SP schema: type: string - name: country in: query description: Sigla do país do endereço required: false example: BR schema: type: string - name: postal_code in: query description: CEP do endereço required: false example: 00000-000 schema: type: string responses: '200': description: OK content: application/json: schema: properties: data: type: array items: type: object properties: id: type: integer street: type: string number: type: string neighborhood: type: string additional: type: string city: type: string state: type: string country: type: string postal_code: type: string created_at: type: string format: date-time updated_at: type: string format: date-time '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Nenhum endereço encontrado! security: - bearerAuth: [] /user/address/{id}: get: tags: - address summary: Retorna um endereço description: Retorna o endereço com o id informado. parameters: - name: id in: path description: Id do endereço que deseja visualizar required: true schema: type: string example: 10 responses: '200': description: OK content: application/json: schema: properties: data: type: array items: type: object properties: id: type: integer street: type: string number: type: string neighborhood: type: string additional: type: string city: type: string state: type: string country: type: string postal_code: type: string created_at: type: string format: date-time updated_at: type: string format: date-time '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Nenhum endereço encontrado com este id! security: - bearerAuth: [] put: tags: - address summary: Edita um endereço description: Edita o endereço com o id informado. parameters: - name: id in: path required: true description: Insira o id do endereço que você deseja alterar as informações schema: type: integer requestBody: content: application/json: schema: $ref: '#/components/schemas/Update-Address' responses: '200': description: OK content: application/json: schema: properties: message: type: string example: Endereço editado com sucesso! address: type: object properties: id: type: integer street: type: string number: type: string neighborhood: type: string additional: type: string city: type: string state: type: string country: type: string postal_code: type: string created_at: type: string format: date-time updated_at: type: string format: date-time '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao editar o endereço! security: - bearerAuth: [] delete: tags: - address summary: Deleta um endereço description: Deleta o endereço do usuário utilizando o id parameters: - name: id in: path required: true description: Insira o id do usuário que você deseja deletar as informações schema: type: integer responses: '200': description: OK content: application/json: schema: properties: data: type: string example: Endereço deletado com sucesso! '401': description: Unauthorized content: application/json: schema: properties: errors: type: string example: Token inválido ou ausente '422': description: Unprocessable Entity content: application/json: schema: properties: errors: type: string example: Erro ao deletar o endereço! security: - bearerAuth: [] components: schemas: User: type: object required: - name - email - password properties: name: type: string example: User Name email: type: string example: example@email.com password: type: string example: '12345678' Login-User: type: object required: - name - password properties: email: type: string example: example@email.com password: type: string example: '12345678' Update-User: type: object properties: name: type: string example: 'User Name' email: type: string example: example@email.com Address: type: object required: - street - number - neighborhood - city - state - country - postal_code properties: street: type: string maxLength: 255 number: type: string maxLength: 255 neighborhood: type: string maxLength: 255 additional: type: string maxLength: 255 city: type: string maxLength: 255 state: type: string maxLength: 1 example: SP country: type: string maxLength: 50 postal_code: type: string maxLength: 50 Update-Address: type: object properties: street: type: string maxLength: 255 number: type: string maxLength: 255 neighborhood: type: string maxLength: 255 additional: type: string maxLength: 255 city: type: string maxLength: 255 state: type: string maxLength: 1 example: SP country: type: string maxLength: 50 postal_code: type: string maxLength: 50 requestBodies: UserArray: description: List of user object content: application/json: schema: type: array items: $ref: '#/components/schemas/User' securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT responses: UnauthorizedError: description: Token inválido ou ausente