Skip to content

Fix Swagger GET request body issue for job endpoints#10

Merged
digitalnomad91 merged 1 commit intomainfrom
fix/swagger-job-endpoint-query-params
Feb 26, 2026
Merged

Fix Swagger GET request body issue for job endpoints#10
digitalnomad91 merged 1 commit intomainfrom
fix/swagger-job-endpoint-query-params

Conversation

@digitalnomad91
Copy link
Member

Summary

Fixes the 'GET Request cannot have a body' error when using the endpoint in Swagger UI.

Changes

  1. JobOrderByDto: Converted from to decorator with flag

    • This ensures sorting parameters are treated as query parameters, not body properties
  2. Api Decorator: Enhanced body type inference logic

    • Now excludes DTOs specified in queriesFrom and pathParamsFrom from automatic body type inference
    • Prevents GET endpoints from incorrectly being assigned a request body
  3. Job Controller:

    • Added JobOrderByDto to queriesFrom arrays in all GET endpoints that use sorting
    • Removed stray code statement in fetchJobs method

Testing

  • GET /jobs endpoint no longer shows request body in Swagger docs
  • Sorting parameters appear as query parameters
  • No TypeScript errors
  • Can successfully test endpoint in Swagger UI without body error

Related Issue

Resolves issue where Swagger UI was generating invalid curl commands with request bodies for GET requests.

- 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
Copilot AI review requested due to automatic review settings February 26, 2026 07:33
@digitalnomad91 digitalnomad91 merged commit cdcdef5 into main Feb 26, 2026
2 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JobOrderByDto to use the shared @Field decorator with inQuery: true so sort fields are documented as query params (not body props).
  • Enhanced @Api decorator body-type inference to exclude DTOs listed in queriesFrom/pathParamsFrom.
  • Added JobOrderByDto to queriesFrom for relevant GET endpoints and removed a stray statement in fetchJobs.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants