{ "schemes": [ "http", "https" ], "swagger": "2.0", "info": { "description": "API para gerenciamento de dados de cidadãos do Rio de Janeiro, incluindo autodeclaração de informações e verificação de contato.", "title": "API RMI", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Suporte RMI", "url": "http://www.rio.rj.gov.br", "email": "suporte@rio.rj.gov.br" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "host": "localhost:8080", "basePath": "/v1", "paths": { "/citizen/ethnicity/options": { "get": { "description": "Retorna a lista de opções válidas de etnia para autodeclaração. Esta lista é usada para validar as atualizações de etnia autodeclarada.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Listar opções de etnia", "responses": { "200": { "description": "Lista de opções de etnia válidas", "schema": { "type": "array", "items": { "type": "string" } } }, "500": { "description": "Erro interno do servidor", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Recupera os dados do cidadão por CPF, combinando dados base com atualizações autodeclaradas. Dados autodeclarados têm precedência sobre dados base. Os resultados são armazenados em cache usando Redis com TTL configurável.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Obter dados do cidadão", "parameters": [ { "maxLength": 11, "minLength": 11, "type": "string", "description": "CPF do cidadão (11 dígitos)", "name": "cpf", "in": "path", "required": true } ], "responses": { "200": { "description": "Dados completos do cidadão", "schema": { "$ref": "#/definitions/models.Citizen" } }, "400": { "description": "Formato de CPF inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "404": { "description": "Cidadão não encontrado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Erro interno do servidor", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/address": { "put": { "security": [ { "BearerAuth": [] } ], "description": "Atualiza ou cria o endereço autodeclarado de um cidadão por CPF. Apenas o campo de endereço é atualizado.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Atualizar endereço autodeclarado", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true }, { "description": "Endereço autodeclarado", "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.SelfDeclaredAddressInput" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handlers.SuccessResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/email": { "put": { "security": [ { "BearerAuth": [] } ], "description": "Atualiza ou cria o email autodeclarado de um cidadão por CPF. Apenas o campo de email é atualizado.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Atualizar email autodeclarado", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true }, { "description": "Email autodeclarado", "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.SelfDeclaredEmailInput" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handlers.SuccessResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/ethnicity": { "put": { "security": [ { "BearerAuth": [] } ], "description": "Atualiza ou cria a etnia autodeclarada de um cidadão por CPF. Apenas o campo de etnia é atualizado. O valor deve ser uma das opções válidas retornadas pelo endpoint /citizen/ethnicity/options.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Atualizar etnia autodeclarada", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true }, { "description": "Etnia autodeclarada", "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.SelfDeclaredRacaInput" } } ], "responses": { "200": { "description": "Etnia atualizada com sucesso", "schema": { "$ref": "#/definitions/handlers.SuccessResponse" } }, "400": { "description": "Formato de CPF inválido ou valor de etnia inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "404": { "description": "Cidadão não encontrado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Erro interno do servidor", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/firstlogin": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Verifica se este é o primeiro login do usuário", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Obter status do primeiro login", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.UserConfigResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "Define o status do primeiro login como falso para um usuário", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Atualizar status do primeiro login", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.UserConfigResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/optin": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Verifica se o usuário optou por receber notificações", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Obter status de opt-in", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.UserConfigOptInResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "Atualiza o status de opt-in do usuário para notificações", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Atualizar status de opt-in", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true }, { "description": "Status de opt-in", "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.UserConfigOptInResponse" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.UserConfigOptInResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/phone": { "put": { "security": [ { "BearerAuth": [] } ], "description": "Atualiza ou cria o telefone autodeclarado de um cidadão por CPF. Apenas o campo de telefone é atualizado (armazenado como pendente até verificado).", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Atualizar telefone autodeclarado", "parameters": [ { "type": "string", "description": "Número do CPF", "name": "cpf", "in": "path", "required": true }, { "description": "Telefone autodeclarado", "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.SelfDeclaredPhoneInput" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handlers.SuccessResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "401": { "description": "Token de autenticação não fornecido ou inválido", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "403": { "description": "Acesso negado", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/citizen/{cpf}/phone/validate": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Validates the verification code sent to the phone number", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "citizen" ], "summary": "Validate phone verification", "parameters": [ { "type": "string", "description": "CPF number", "name": "cpf", "in": "path", "required": true }, { "description": "Verification code and phone", "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.PhoneVerificationValidateRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handlers.SuccessResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handlers.ErrorResponse" } } } } }, "/health": { "get": { "description": "Verifica a saúde da API e suas dependências (MongoDB e Redis). Retorna status detalhado para cada serviço.", "produces": [ "application/json" ], "tags": [ "health" ], "summary": "Verificação de saúde", "responses": { "200": { "description": "Todos os serviços estão saudáveis", "schema": { "$ref": "#/definitions/handlers.HealthResponse" } }, "503": { "description": "Um ou mais serviços estão indisponíveis", "schema": { "$ref": "#/definitions/handlers.HealthResponse" } } } } } }, "definitions": { "handlers.ErrorResponse": { "type": "object", "properties": { "error": { "type": "string" } } }, "handlers.HealthResponse": { "type": "object", "properties": { "services": { "type": "object", "additionalProperties": { "type": "string" } }, "status": { "type": "string" }, "timestamp": { "type": "string" } } }, "handlers.SuccessResponse": { "type": "object", "properties": { "message": { "type": "string" } } }, "models.Citizen": { "type": "object", "properties": { "cpf": { "type": "string" }, "cpf_particao": { "type": "integer" }, "datalake": { "$ref": "#/definitions/models.Datalake" }, "documentos": { "$ref": "#/definitions/models.Documentos" }, "email": { "$ref": "#/definitions/models.Email" }, "endereco": { "$ref": "#/definitions/models.Endereco" }, "mae": { "$ref": "#/definitions/models.Mae" }, "menor_idade": { "type": "boolean" }, "nascimento": { "$ref": "#/definitions/models.Nascimento" }, "nome": { "type": "string" }, "nome_social": { "type": "string" }, "obito": { "$ref": "#/definitions/models.Obito" }, "raca": { "type": "string" }, "row_number": { "type": "integer" }, "saude": { "$ref": "#/definitions/models.Saude" }, "sexo": { "type": "string" }, "telefone": { "$ref": "#/definitions/models.Telefone" } } }, "models.ClinicaFamilia": { "type": "object", "properties": { "id_cnes": { "type": "string" }, "indicador": { "type": "boolean" }, "nome": { "type": "string" }, "telefone": { "type": "string" } } }, "models.Datalake": { "type": "object", "properties": { "last_updated": { "type": "string" } } }, "models.Documentos": { "type": "object", "properties": { "cns": { "type": "array", "items": { "type": "string" } } } }, "models.Email": { "type": "object", "properties": { "alternativo": { "type": "array", "items": { "type": "integer" } }, "indicador": { "type": "boolean" }, "principal": { "$ref": "#/definitions/models.EmailPrincipal" } } }, "models.EmailPrincipal": { "type": "object", "properties": { "origem": { "type": "string" }, "sistema": { "type": "string" }, "valor": { "type": "string" } } }, "models.Endereco": { "type": "object", "properties": { "alternativo": { "type": "array", "items": { "type": "integer" } }, "indicador": { "type": "boolean" }, "principal": { "$ref": "#/definitions/models.EnderecoPrincipal" } } }, "models.EnderecoPrincipal": { "type": "object", "properties": { "bairro": { "type": "string" }, "cep": { "type": "string" }, "complemento": { "type": "string" }, "estado": { "type": "string" }, "logradouro": { "type": "string" }, "municipio": { "type": "string" }, "numero": { "type": "string" }, "origem": { "type": "string" }, "sistema": { "type": "string" }, "tipo_logradouro": { "type": "string" } } }, "models.EquipeSaudeFamilia": { "type": "object", "properties": { "id_ine": { "type": "string" }, "indicador": { "type": "boolean" }, "nome": { "type": "string" }, "telefone": { "type": "string" } } }, "models.Mae": { "type": "object", "properties": { "cpf": { "type": "string" }, "nome": { "type": "string" } } }, "models.Nascimento": { "type": "object", "properties": { "data": { "type": "string" }, "municipio": { "type": "string" }, "municipio_id": { "type": "string" }, "pais": { "type": "string" }, "pais_id": { "type": "string" }, "uf": { "type": "string" } } }, "models.Obito": { "type": "object", "properties": { "ano": { "type": "integer" }, "indicador": { "type": "boolean" } } }, "models.PhoneVerificationValidateRequest": { "type": "object", "required": [ "code", "ddd", "ddi", "valor" ], "properties": { "code": { "type": "string" }, "ddd": { "type": "string" }, "ddi": { "type": "string" }, "valor": { "type": "string" } } }, "models.Saude": { "type": "object", "properties": { "clinica_familia": { "$ref": "#/definitions/models.ClinicaFamilia" }, "equipe_saude_familia": { "$ref": "#/definitions/models.EquipeSaudeFamilia" } } }, "models.SelfDeclaredAddressInput": { "type": "object", "required": [ "bairro", "cep", "estado", "logradouro", "municipio", "numero" ], "properties": { "bairro": { "type": "string" }, "cep": { "type": "string" }, "complemento": { "type": "string" }, "estado": { "type": "string" }, "logradouro": { "type": "string" }, "municipio": { "type": "string" }, "numero": { "type": "string" }, "tipo_logradouro": { "type": "string" } } }, "models.SelfDeclaredEmailInput": { "type": "object", "required": [ "valor" ], "properties": { "valor": { "type": "string" } } }, "models.SelfDeclaredPhoneInput": { "type": "object", "required": [ "ddd", "ddi", "valor" ], "properties": { "ddd": { "type": "string" }, "ddi": { "type": "string" }, "valor": { "type": "string" } } }, "models.SelfDeclaredRacaInput": { "type": "object", "required": [ "valor" ], "properties": { "valor": { "type": "string" } } }, "models.Telefone": { "type": "object", "properties": { "alternativo": { "type": "array", "items": { "type": "integer" } }, "indicador": { "type": "boolean" }, "principal": { "$ref": "#/definitions/models.TelefonePrincipal" } } }, "models.TelefonePrincipal": { "type": "object", "properties": { "ddd": { "type": "string" }, "ddi": { "type": "string" }, "origem": { "type": "string" }, "sistema": { "type": "string" }, "valor": { "type": "string" } } }, "models.UserConfigOptInResponse": { "type": "object", "properties": { "optin": { "type": "boolean" } } }, "models.UserConfigResponse": { "type": "object", "properties": { "firstlogin": { "type": "boolean" } } } }, "securityDefinitions": { "BearerAuth": { "description": "Tipo: Bearer token. Exemplo: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "type": "apiKey", "name": "Authorization", "in": "header" } }, "tags": [ { "description": "Operações relacionadas a cidadãos, incluindo consulta e atualização de dados autodeclarados", "name": "citizen" }, { "description": "Operações de verificação de saúde da API", "name": "health" } ] }