You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Document error response format (RFC 7807) in README (#55)
Add an "Error responses" subsection covering:
- The application/problem+json body shape (type, title, status,
detail, pointer, keyword) emitted by ProblemDetailRenderer.
- Single-error reporting (first failure wins).
- JSON-Pointer pointer field per RFC 6901.
- Common keyword values for validation failures.
- An example body for a typical coercion failure.
- 404 / 405 / 500 surfaces and how to override via ExceptionHandler.
Copy file name to clipboardExpand all lines: README.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,42 @@ Form-field coercion mirrors the rules already used at the parameter boundary: th
114
114
115
115
Both built-in parsers honour the `charset=` parameter on the `Content-Type` header (default UTF-8). Unknown charsets fall back to UTF-8.
116
116
117
+
### Error responses (RFC 7807)
118
+
119
+
Validation failures — missing required fields, type mismatches, unsupported content types, coercion errors, malformed bodies — produce an `HTTP 400 Bad Request` response with body media type `application/problem+json`, following [RFC 7807](https://datatracker.ietf.org/doc/html/rfc7807).
120
+
121
+
A single error is reported per request (first failure wins). The response body has these fields:
|`type`| string | Always `about:blank` (no per-error type URI). |
126
+
|`title`| string | Always `Bad Request`. |
127
+
|`status`| integer | Always `400`. |
128
+
|`detail`| string | Human-readable description of the failure (e.g. `expected integer`). |
129
+
|`pointer`| string |[RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) JSON-Pointer to the failing location (e.g. `/body/age`, `/query/limit`, `/path/id`, or `/body` for body-wide errors). |
Example body for `POST /form-echo` with `age=abc` (`age` is declared as `integer`):
133
+
134
+
```json
135
+
{
136
+
"type": "about:blank",
137
+
"title": "Bad Request",
138
+
"status": 400,
139
+
"detail": "expected integer",
140
+
"pointer": "/age",
141
+
"keyword": "type"
142
+
}
143
+
```
144
+
145
+
Other error responses:
146
+
147
+
-**404 Not Found** — no route matches the request path (no body).
148
+
-**405 Method Not Allowed** — path matches but the HTTP method isn't declared. Includes an `Allow` header listing permitted methods (no body).
149
+
-**500 Internal Server Error** — uncaught exception from a handler. No body by default; override `ExceptionHandler` if you need a different envelope.
150
+
151
+
The error mapping is performed by `Handlers.defaultExceptionHandler()`. Pass your own `ExceptionHandler` to `OpenApiServer.builder().exceptionHandler(...)` if you need a different response shape (e.g. multi-error collection, custom problem types, locale-aware `detail`).
152
+
117
153
### Extra (non-OpenAPI) handlers
118
154
119
155
Mount handlers at arbitrary paths outside the OpenAPI spec — useful for liveness probes,
0 commit comments