Skip to content

v1.4.0

Choose a tag to compare

@Fcmam5 Fcmam5 released this 01 May 05:30
· 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) — ProblemDetailsException now accepts an optional retryAfter field (number, Date, or string). The HttpExceptionFilter serializes 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).
  • @ApiProblemResponse decorator (#32) — optional Swagger/OpenAPI integration via the nest-problem-details-filter/swagger subpath export. Stack it once per status code to auto-generate:
    • The canonical RFC 9457 ProblemDetails schema under content['application/problem+json']
    • A response example with resolved type, title, and status
    • Retry-After header documentation when retryAfter is 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) { ... }
  • 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.
  • httpErrors option on @ApiProblemResponse — pass the same custom status-to-type map you inject into HttpExceptionFilter via HTTP_ERRORS_MAP_KEY so 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 404 example matches the actual HTTP response body emitted by the filter.

Fixes

  • resolveProblemUri normalization — 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 via URL, stripped of search/hash, and normalized with a trailing slash on pathname before resolving the relative type. Prevents the old string-append bug where ?x=1/ corrupted path resolution.
  • Retry-After Date schema — the decorator no longer documents retryAfter: Date with format: 'date-time' (RFC 3339). The runtime emits IMF-fixdate via toUTCString() (e.g. Wed, 21 Oct 2026 07:28:00 GMT), so the schema now correctly uses a plain string with an explicit IMF-fixdate description.
  • Filter type resolution — switched to WHATWG URL constructor for joining baseUri + type, matching the decorator's resolution logic and eliminating manual string-concatenation edge cases.
  • TypeScript rootDir — dropped the src-only rootDir in tsconfig.json so editors no longer throw errors on files under tests/.

Changes

  • Repository structuresrc/filters/ split into src/filter/ and src/exception/ for clearer separation of concerns.
  • CI — added Coveralls coverage reporting to the GitHub Actions workflow; badge added to README.
  • Documentation — updated docs/usage.md and docs/openapi.md with Retry-After and Swagger decorator examples, including baseUri and httpErrors alignment guidance.

Full Changelog: v1.3.0...v1.4.0