swagger-api / swagger-api/swagger-codegen

swift codegen does not support query parameters on POST

Open
#1,564 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Swift help wanted Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

POST methods with query parameter types map to Alamofire.ParameterEncoding.URL which means they are sent in the body of the request as application/x-www-form-urlencoded.

I need to support POST methods with query parameter types that map to Alamofire.ParameterEncoding.URLEncodedInURL. The generated code does not make it easy to support this due to its use of a boolean flag isBody, rather than an enumeration.

The following line in AlamofireImplementations.swift within the execute method is the issue:
let encoding = isBody ? Alamofire.ParameterEncoding.JSON : Alamofire.ParameterEncoding.URL

I believe the solution would be to refactor the isBody variable away in favor of an explicit ParameterEncoding type enum. This would make it easy to override the encoding behavior at the individual method level.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in AlamofireImplementations.swift, in the execute method, and inspect how the isBody flag selects ParameterEncoding.URL or JSON. Trace the generated Swift code for POST query parameters and define the expected per-method encoding behavior. Done means POST query parameters can use Alamofire.ParameterEncoding.URLEncodedInURL without breaking existing body and URL encoding paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.