Skip to content

Commit

Permalink
Merge pull request #42 from danielgtaylor/422-response
Browse files Browse the repository at this point in the history
fix: add 422 convenience response
  • Loading branch information
danielgtaylor authored Apr 14, 2022
2 parents f67bd7b + f809744 commit 02414da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions responses/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ func RequestEntityTooLarge() huma.Response {
return errorResponse(http.StatusRequestEntityTooLarge)
}

// UnprocessableEntity HTTP 422 response with a structured error body (e.g. JSON).
func UnprocessableEntity() huma.Response {
return errorResponse(http.StatusUnprocessableEntity)
}

// PreconditionRequired HTTP 428 response with a structured error body (e.g. JSON).
func PreconditionRequired() huma.Response {
return errorResponse(http.StatusPreconditionRequired)
Expand Down
2 changes: 2 additions & 0 deletions responses/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var funcs = struct {
Conflict,
PreconditionFailed,
RequestEntityTooLarge,
UnprocessableEntity,
PreconditionRequired,
InternalServerError,
NotImplemented,
Expand Down Expand Up @@ -71,6 +72,7 @@ func TestResponses(t *testing.T) {
http.StatusConflict,
http.StatusPreconditionFailed,
http.StatusRequestEntityTooLarge,
http.StatusUnprocessableEntity,
http.StatusPreconditionRequired,
http.StatusInternalServerError,
http.StatusNotImplemented,
Expand Down

0 comments on commit 02414da

Please sign in to comment.