Repository navigation
Conversation
|
@Jovinull is attempting to deploy a commit to the BrasilAPI Team on Vercel. A member of the Team first needs to authorize it. |
|
Contributor
Author
|
Fechando este PR. Após abrir, notei que o #799 (do @felipeflfranca, autor da própria issue #798) já está aberto há 13 dias trazendo a mesma correção e abordagem equivalente. O trabalho dele veio primeiro e merece prioridade na fila de review. Falha minha não ter feito a checagem de duplicidade antes de subir o meu — fica registrado como aprendizado. |
Closed
20 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Atende à #798.
O endpoint
/api/ibge/uf/v1/:codefoi projetado para aceitar tanto sigla (PI) quanto código numérico do IBGE (22), mas retornava 404 sempre que o parâmetro era um código numérico. A causa está emutil/mapUfToUfCode.js, que só consultava o mapa por sigla — quando recebia"22", não encontrava noUF_CODE_MAPPERe lançavaNotFoundError, fazendo oPromise.alldo handler rejeitar antes da resposta válida degetUfByCode.Mudanças:
util/mapUfToUfCode.js: passa a aceitar tanto sigla (PI) quanto código numérico do IBGE (22); retorna o próprio código quando ele já é um valor válido doUF_CODE_MAPPER.util/mapUfToUfCode.js: corrige a instanciação doNotFoundErrorque estava sendo chamada com string em vez de objeto, fazendo o campomessagechegar vazio na resposta. Agora usa a mensagem canônica"UF não encontrada.", alinhada com othrowexplícito do handler.tests/ibge-uf-v1.test.js: trocatoEqualportoMatchObjectnas asserções positivas e cobre os campospopulacao_estimadaeperiodo, que já constam no schema OpenAPI (pages/docs/doc/ibge.json) desde a introdução degetUfEstimatePopulationByCode.Validação local com
npm test -- tests/ibge-uf-v1.test.js: 18/18 passando. Bateria cURL cobrindo/22,/PI,/sc(200),/99,/SJ(404 com mensagem padronizada) e/v1(listagem) também passou.