implement OpenAPI contributor integration for rate limiting and response headers
This commit is contained in:
@@ -92,6 +92,9 @@ public class PriceHandler extends RequestHandler { ... }
|
||||
Each annotation is processed by its own processor; Flash collects all middleware and
|
||||
composes them in processor registration order.
|
||||
|
||||
When `flash-ext-openapi` is installed, `@Limit` also contributes OpenAPI response
|
||||
headers (`X-RateLimit-*`) and `Retry-After` on `429` automatically.
|
||||
|
||||
```java
|
||||
@Route(method = HttpMethod.DELETE, path = "/admin/users/{id}")
|
||||
@Limit(key = "auth_user", requests = 5, window = 1, windowUnit = TimeUnit.MINUTES)
|
||||
|
||||
@@ -117,6 +117,12 @@ and **instead of** calling it on rejected requests. This means:
|
||||
|
||||
## Integration with Swagger UI (flash-ext-openapi)
|
||||
|
||||
Rate-limit headers are not currently injected into the OpenAPI spec. If you want to
|
||||
document them, add them manually via `@ApiOperation` on the handler class using the
|
||||
response headers section of the OpenAPI spec.
|
||||
When `flash-ext-openapi` is installed, handlers annotated with `@Limit` automatically
|
||||
contribute rate-limit response headers to generated OpenAPI responses:
|
||||
|
||||
- `X-RateLimit-Limit`
|
||||
- `X-RateLimit-Remaining`
|
||||
- `X-RateLimit-Reset`
|
||||
- `Retry-After` on `429`
|
||||
|
||||
If `429` is not manually declared, OpenAPI auto-adds `429 Too Many Requests`.
|
||||
|
||||
Reference in New Issue
Block a user