v1.4.0
·
44 commits
to develop
since this release
Immutable
release. Only release title and notes can be modified.
What's Changed
This release adds Retry-After header support per RFC 9110 §10.2.3, an optional Swagger/OpenAPI decorator (@ApiProblemResponse) for auto-documenting application/problem+json responses, and a set of shared resolvers that guarantee OpenAPI examples match the runtime wire format.
Features
- Retry-After header support (#21) —
ProblemDetailsExceptionnow accepts an optionalretryAfterfield (number, Date, or string). TheHttpExceptionFilterserializes it as delta-seconds or IMF-fixdate per RFC 9110 §10.2.3, and guards against invalid values (negative numbers, NaN, blank strings, invalid Dates). @ApiProblemResponsedecorator (#32) — optional Swagger/OpenAPI integration via thenest-problem-details-filter/swaggersubpath export. Stack it once per status code to auto-generate:- The canonical RFC 9457
ProblemDetailsschema undercontent['application/problem+json'] - A response example with resolved
type,title, andstatus Retry-Afterheader documentation whenretryAfteris provided
import { ApiProblemResponse } from 'nest-problem-details-filter/swagger'; @ApiProblemResponse({ status: 404, type: 'not-found', title: 'Dragon not found' }) @ApiProblemResponse({ status: 429, type: 'rate-limit-exceeded', retryAfter: 3600 }) findOne(@Param('id') id: string) { ... }
- The canonical RFC 9457
- Shared resolvers (
resolveProblemTitle,resolveProblemType,resolveProblemUri) — extracted into a dedicated module so the decorator and the filter consume the exact same resolution logic. This eliminates drift between documented examples and runtime responses. httpErrorsoption on@ApiProblemResponse— pass the same custom status-to-type map you inject intoHttpExceptionFilterviaHTTP_ERRORS_MAP_KEYso the OpenAPI example uses your overrides instead of built-in defaults.- End-to-end Swagger integration test — generates a full OpenAPI document, compares it against a committed fixture, and verifies the documented
404example matches the actual HTTP response body emitted by the filter.
Fixes
resolveProblemUrinormalization — base URI strings with query strings or hash fragments (e.g.https://api.example.com/problems?x=1#frag, Angular-style/#/paths) are now parsed viaURL, stripped ofsearch/hash, and normalized with a trailing slash onpathnamebefore resolving the relativetype. Prevents the old string-append bug where?x=1/corrupted path resolution.- Retry-After Date schema — the decorator no longer documents
retryAfter: Datewithformat: 'date-time'(RFC 3339). The runtime emits IMF-fixdate viatoUTCString()(e.g.Wed, 21 Oct 2026 07:28:00 GMT), so the schema now correctly uses a plainstringwith an explicit IMF-fixdate description. - Filter type resolution — switched to WHATWG
URLconstructor for joiningbaseUri+type, matching the decorator's resolution logic and eliminating manual string-concatenation edge cases. - TypeScript
rootDir— dropped thesrc-onlyrootDirintsconfig.jsonso editors no longer throw errors on files undertests/.
Changes
- Repository structure —
src/filters/split intosrc/filter/andsrc/exception/for clearer separation of concerns. - CI — added Coveralls coverage reporting to the GitHub Actions workflow; badge added to README.
- Documentation — updated
docs/usage.mdanddocs/openapi.mdwith Retry-After and Swagger decorator examples, includingbaseUriandhttpErrorsalignment guidance.
Full Changelog: v1.3.0...v1.4.0