nest icon indicating copy to clipboard operation
nest copied to clipboard

feat(fastify): add decorator for custom schema

Open piotrfrankowski opened this issue 8 months ago • 1 comments
trafficstars

Add an ability to attach json schema to request with a RequestSchema decorator

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [x] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Other... Please describe:

What is the current behavior?

Currently, there is no easy way of using fastify's schema property and adding a response schema can have positive impact on performance source

Issue Number: N/A

What is the new behavior?

This PR adds a new decorator RequestSchema that takes a schema object and sets it as schema property on fastify route doc

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

piotrfrankowski avatar Mar 17 '25 11:03 piotrfrankowski

Pull Request Test Coverage Report for Build 4564b87f-2f8f-4f0f-8778-fcf6b60673ff

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 88.93%

Totals Coverage Status
Change from base Build c493f148-f1dd-4b7d-a940-d13270fde234: 0.007%
Covered Lines: 7182
Relevant Lines: 8076

💛 - Coveralls

coveralls avatar Mar 17 '25 11:03 coveralls

This should include some documentation on how to use it.

jadejr avatar Jun 24 '25 00:06 jadejr

Oh, and it should have example usage in the fastify example.

jadejr avatar Jun 26 '25 19:06 jadejr

LGTM

kamilmysliwiec avatar Jul 15 '25 10:07 kamilmysliwiec