Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ curl -X QUERY "http://localhost:3000/v1/validate" -H "Content-Type: application/
}
```

### Example error response

All error responses are returned using the `application/problem+json` media type,
in accordance with [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457.html).

```http
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
```

```json
{
"title": "empty body",
"detail": "need a body to validate",
"status": 400
}
```

## Contributing

Contributing is always appreciated, see [CONTRIBUTING.md](CONTRIBUTING.md).
Expand Down
5 changes: 2 additions & 3 deletions internal/handlers/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gofiber/fiber/v2"
publiccodeParser "github.com/italia/publiccode-parser-go/v5"
"github.com/italia/publiccode-validator-api/internal/common"
)

type PubliccodeymlValidatorHandler struct {
Expand Down Expand Up @@ -43,9 +44,7 @@ func (vh *PubliccodeymlValidatorHandler) Query(ctx *fiber.Ctx) error {
// }

if len(ctx.Body()) == 0 {
return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "empty body",
})
return common.Error(fiber.StatusBadRequest, "empty body", "need a body to validate")
}

results := make(publiccodeParser.ValidationResults, 0)
Expand Down