Fix Swagger GET request body issue for job endpoints#10
Merged
digitalnomad91 merged 1 commit intomainfrom Feb 26, 2026
Merged
Conversation
- Fix JobOrderByDto to use @field decorator with inQuery flag - Update @Api decorator to exclude queriesFrom/pathParamsFrom DTOs from body inference - Add JobOrderByDto to queriesFrom arrays in job controller endpoints - Remove stray code statement in fetchJobs method This fixes the 'GET Request cannot have a body' error in Swagger docs UI
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Swagger/OpenAPI documentation generation so GET job endpoints no longer incorrectly show a request body (which causes Swagger UI to generate invalid curl commands), by ensuring sorting DTOs are treated as query parameters and by improving automatic body type inference.
Changes:
- Updated
JobOrderByDtoto use the shared@Fielddecorator withinQuery: trueso sort fields are documented as query params (not body props). - Enhanced
@Apidecorator body-type inference to exclude DTOs listed inqueriesFrom/pathParamsFrom. - Added
JobOrderByDtotoqueriesFromfor relevant GET endpoints and removed a stray statement infetchJobs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/jobs/job.controller.ts | Ensures sorting DTO is included in queriesFrom for GET endpoints (and removes a stray statement). |
| src/jobs/dto/job-order-by.dto.ts | Converts sort DTO fields to @Field(..., inQuery: true) so Swagger documents them as query params. |
| src/common/decorators/api.decorator.ts | Prevents query/path DTOs from being inferred as request bodies during automatic body inference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the 'GET Request cannot have a body' error when using the endpoint in Swagger UI.
Changes
JobOrderByDto: Converted from to decorator with flag
Api Decorator: Enhanced body type inference logic
queriesFromandpathParamsFromfrom automatic body type inferenceJob Controller:
JobOrderByDtotoqueriesFromarrays in all GET endpoints that use sortingfetchJobsmethodTesting
Related Issue
Resolves issue where Swagger UI was generating invalid curl commands with request bodies for GET requests.