OpenAPITools / OpenAPITools/openapi-generator
[REQ] [swift5] Split RequestBuilder parameters
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
I would like to suggest splitting RequestBuilder parameters.
Now, the parameters contains multiple meanings such as query, body, form.
When I saw generated swift5 code for the first time, I was so confused.
I think it's not easy to maintain these codes for iOS Developer.
I suggest split the paramters. e.g queryParameters, bodyParameters, formParameters.
It doesn't affect the behavior by fixing code.
If you agree with my opinion, I will create PR.
The following code is what I'm thinking.
// Before
open class RequestBuilder<T> {
public let parameters: [String: Any]?
public let URLString: String
}
// After
open class RequestBuilder<T> {
public let queryParameters: [String: Any]?
public let formParameters: [String: Any]?
public let bodyParameters: [String: Any]?
public let path: String // not contain query parameters
}
// URLSessionImplementations or AlamofireImplementations
func createURLRequest()-> URLRequest {
// set query parameters
if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false), !parameters.isEmpty {
urlComponents.queryItems = APIHelper.mapValuesToQueryItems(parameters)
urlRequest.url = urlComponents.url
}
// set bodyParameters or formParameters
return urlRequest
}
Describe alternatives you've considered
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated swift5 RequestBuilder and the URLSessionImplementations or AlamofireImplementations mentioned in the proposal. Trace how the current parameters are used for query, body, and form data, and how the URL path is represented. Done means those meanings are represented separately without changing request behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100