Skip to content

Commit

Permalink
atualizando documentação e teste
Browse files Browse the repository at this point in the history
  • Loading branch information
joellensilva committed Dec 19, 2024
1 parent c403c47 commit a912b9c
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 62 deletions.
9 changes: 9 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,9 @@ const docTemplate = `{
"id_orgao": {
"type": "string"
},
"inconsistente": {
"type": "boolean"
},
"indice_transparencia": {
"$ref": "#/definitions/papi.score"
},
Expand Down Expand Up @@ -1309,6 +1312,9 @@ const docTemplate = `{
"descontos_por_mes": {
"type": "number"
},
"inconsistente": {
"type": "boolean"
},
"meses_com_dados": {
"type": "integer"
},
Expand Down Expand Up @@ -1686,6 +1692,9 @@ const docTemplate = `{
"error": {
"$ref": "#/definitions/uiapi.procError"
},
"inconsistente": {
"type": "boolean"
},
"mes": {
"type": "integer"
},
Expand Down
9 changes: 9 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@
"id_orgao": {
"type": "string"
},
"inconsistente": {
"type": "boolean"
},
"indice_transparencia": {
"$ref": "#/definitions/papi.score"
},
Expand Down Expand Up @@ -1300,6 +1303,9 @@
"descontos_por_mes": {
"type": "number"
},
"inconsistente": {
"type": "boolean"
},
"meses_com_dados": {
"type": "integer"
},
Expand Down Expand Up @@ -1677,6 +1683,9 @@
"error": {
"$ref": "#/definitions/uiapi.procError"
},
"inconsistente": {
"type": "boolean"
},
"mes": {
"type": "integer"
},
Expand Down
6 changes: 6 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ definitions:
$ref: '#/definitions/papi.miError'
id_orgao:
type: string
inconsistente:
type: boolean
indice_transparencia:
$ref: '#/definitions/papi.score'
mes:
Expand Down Expand Up @@ -364,6 +366,8 @@ definitions:
type: number
descontos_por_mes:
type: number
inconsistente:
type: boolean
meses_com_dados:
type: integer
num_membros:
Expand Down Expand Up @@ -612,6 +616,8 @@ definitions:
type: number
error:
$ref: '#/definitions/uiapi.procError'
inconsistente:
type: boolean
mes:
type: integer
outras_remuneracoes:
Expand Down
122 changes: 61 additions & 61 deletions papi/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ func (h handler) V1GetAgencyById(c echo.Context) error {
return c.JSON(http.StatusOK, agency)
}

// @ID GetAgencyById
// @Tags public_api
// @Description Busca um órgão específico utilizando seu ID.
// @Produce json
// @Param orgao path string true "ID do órgão. Exemplos: tjal, tjba, mppb."
// @Success 200 {object} agency "Requisição bem sucedida."
// @Failure 404 {string} string "Órgão não encontrado."
// @Router /v2/orgao/{orgao} [get]
// @ID GetAgencyById
// @Tags public_api
// @Description Busca um órgão específico utilizando seu ID.
// @Produce json
// @Param orgao path string true "ID do órgão. Exemplos: tjal, tjba, mppb."
// @Success 200 {object} agency "Requisição bem sucedida."
// @Failure 404 {string} string "Órgão não encontrado."
// @Router /v2/orgao/{orgao} [get]
func (h handler) V2GetAgencyById(c echo.Context) error {
agencyName := c.Param("orgao")
strAgency, err := h.client.Db.GetAgency(agencyName)
Expand Down Expand Up @@ -92,13 +92,13 @@ func (h handler) V1GetAllAgencies(c echo.Context) error {
return c.JSON(http.StatusOK, agencies)
}

// @ID GetAllAgencies
// @Tags public_api
// @Description Busca todos os órgãos disponíveis.
// @Produce json
// @Success 200 {object} []agency "Requisição bem sucedida."
// @Failure 500 {string} string "Erro interno do servidor."
// @Router /v2/orgaos [get]
// @ID GetAllAgencies
// @Tags public_api
// @Description Busca todos os órgãos disponíveis.
// @Produce json
// @Success 200 {object} []agency "Requisição bem sucedida."
// @Failure 500 {string} string "Erro interno do servidor."
// @Router /v2/orgaos [get]
func (h handler) V2GetAllAgencies(c echo.Context) error {
strAgencies, err := h.client.Db.GetAllAgencies()
if err != nil {
Expand Down Expand Up @@ -264,17 +264,17 @@ func (h handler) GetMonthlyInfo(c echo.Context) error {
return c.JSON(http.StatusOK, sumMI)
}

// @ID GetMonthlyInfo
// @Tags public_api
// @Description Busca um dado mensal de um órgão
// @Produce json
// @Success 200 {object} summaryzedMI "Requisição bem sucedida"
// @Failure 400 {string} string "Parâmetros inválidos"
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
// @Param ano path int true "Ano"
// @Param orgao path string true "Órgão"
// @Param mes path int true "Mês"
// @Router /v2/dados/{orgao}/{ano}/{mes} [get]
// @ID GetMonthlyInfo
// @Tags public_api
// @Description Busca um dado mensal de um órgão
// @Produce json
// @Success 200 {object} summaryzedMI "Requisição bem sucedida"
// @Failure 400 {string} string "Parâmetros inválidos"
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
// @Param ano path int true "Ano"
// @Param orgao path string true "Órgão"
// @Param mes path int true "Mês"
// @Router /v2/dados/{orgao}/{ano}/{mes} [get]
func (h handler) V2GetMonthlyInfo(c echo.Context) error {
year, err := strconv.Atoi(c.Param("ano"))
if err != nil {
Expand Down Expand Up @@ -398,16 +398,16 @@ func (h handler) V2GetMonthlyInfo(c echo.Context) error {
return c.JSON(http.StatusOK, sumMI)
}

// @ID GetMonthlyInfosByYear
// @Tags public_api
// @Description Busca os dados mensais de um órgão por ano
// @Produce json
// @Success 200 {object} []summaryzedMI "Requisição bem sucedida"
// @Failure 400 {string} string "Parâmetros inválidos"
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
// @Param ano path int true "Ano"
// @Param orgao path string true "Órgão"
// @Router /v2/dados/{orgao}/{ano} [get]
// @ID GetMonthlyInfosByYear
// @Tags public_api
// @Description Busca os dados mensais de um órgão por ano
// @Produce json
// @Success 200 {object} []summaryzedMI "Requisição bem sucedida"
// @Failure 400 {string} string "Parâmetros inválidos"
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
// @Param ano path int true "Ano"
// @Param orgao path string true "Órgão"
// @Router /v2/dados/{orgao}/{ano} [get]
func (h handler) GetMonthlyInfosByYear(c echo.Context) error {
year, err := strconv.Atoi(c.Param("ano"))
if err != nil {
Expand Down Expand Up @@ -532,16 +532,16 @@ func (h handler) GetMonthlyInfosByYear(c echo.Context) error {
return c.JSON(http.StatusOK, sumMI)
}

// @ID GetAggregateIndexesWithParams
// @Tags public_api
// @Description Busca as informações de índices de um grupo ou órgão específico.
// @Produce json
// @Success 200 {object} []aggregateIndexes "Requisição bem sucedida."
// @Failure 400 {string} string "Requisição inválida."
// @Failure 500 {string} string "Erro interno do servidor."
// @Param param path string true "'grupo' ou 'orgao'"
// @Param valor path string true "Jurisdição ou ID do órgao"
// @Router /v2/indice/{param}/{valor} [get]
// @ID GetAggregateIndexesWithParams
// @Tags public_api
// @Description Busca as informações de índices de um grupo ou órgão específico.
// @Produce json
// @Success 200 {object} []aggregateIndexes "Requisição bem sucedida."
// @Failure 400 {string} string "Requisição inválida."
// @Failure 500 {string} string "Erro interno do servidor."
// @Param param path string true "'grupo' ou 'orgao'"
// @Param valor path string true "Jurisdição ou ID do órgao"
// @Router /v2/indice/{param}/{valor} [get]
func (h handler) V2GetAggregateIndexesWithParams(c echo.Context) error {
param := c.Param("param")
valor := c.Param("valor")
Expand Down Expand Up @@ -689,13 +689,13 @@ func (h handler) V2GetAggregateIndexesWithParams(c echo.Context) error {
return c.JSON(http.StatusOK, aggregate)
}

// @ID GetAggregateIndexes
// @Tags public_api
// @Description Busca as informações de índices de todos os órgãos.
// @Produce json
// @Success 200 {object} []aggregateIndexesByGroup "Requisição bem sucedida."
// @Failure 500 {string} string "Erro interno do servidor."
// @Router /v2/indice [get]
// @ID GetAggregateIndexes
// @Tags public_api
// @Description Busca as informações de índices de todos os órgãos.
// @Produce json
// @Success 200 {object} []aggregateIndexesByGroup "Requisição bem sucedida."
// @Failure 500 {string} string "Erro interno do servidor."
// @Router /v2/indice [get]
func (h handler) V2GetAggregateIndexes(c echo.Context) error {
agregado := c.QueryParam("agregado")
detalhe := c.QueryParam("detalhe")
Expand Down Expand Up @@ -799,14 +799,14 @@ func (h handler) V2GetAggregateIndexes(c echo.Context) error {
return c.JSON(http.StatusOK, dados)
}

// @ID GetAllAgencyInformation
// @Tags public_api
// @Description Busca todas as informações de um órgão específico.
// @Produce json
// @Success 200 {object} allAgencyInformation "Requisição bem sucedida."
// @Failure 400 {string} string "Requisição inválida."
// @Param orgao path string true "órgão"
// @Router /v2/dados/{orgao} [get]
// @ID GetAllAgencyInformation
// @Tags public_api
// @Description Busca todas as informações de um órgão específico.
// @Produce json
// @Success 200 {object} allAgencyInformation "Requisição bem sucedida."
// @Failure 400 {string} string "Requisição inválida."
// @Param orgao path string true "órgão"
// @Router /v2/dados/{orgao} [get]
func (h handler) V2GetAllAgencyInformation(c echo.Context) error {
agency := strings.ToLower(c.Param("orgao"))

Expand Down
3 changes: 2 additions & 1 deletion uiapi/uiapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,8 @@ func (g getTotalsOfAgencyYear) testWhenDataExists(t *testing.T) {
"licenca_compensatoria": 120,
"auxilio_saude": 300,
"outras": 200
}
},
"inconsistente": false
}
],
"package": {
Expand Down

0 comments on commit a912b9c

Please sign in to comment.