-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
[swift5] fix: annotate the query-parameter dictionary so large operations type-check #24871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -429,11 +429,12 @@ extension {{projectName}}API { | |
| {{/hasFormParams}} | ||
| {{/bodyParam}}{{#hasQueryParams}} | ||
| var localVariableUrlComponents = URLComponents(string: localVariableURLString) | ||
| localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([{{^queryParams}}:{{/queryParams}} | ||
| let localVariableQueryParameters: [String: (wrappedValue: Any?, isExplode: Bool)] = [{{^queryParams}}:{{/queryParams}} | ||
| {{#queryParams}} | ||
| {{> _param}}, | ||
| {{/queryParams}} | ||
| ]){{/hasQueryParams}}{{^hasQueryParams}} | ||
| ] | ||
| localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems(localVariableQueryParameters){{/hasQueryParams}}{{^hasQueryParams}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The PR description states the typed-dictionary fix was also applied to the Swift6 template and that Swift6 samples should be re-generated, but the diff only changes swift5/api.mustache. swift6/api.mustache:307 still passes the unannotated dictionary literal directly to mapValuesToQueryItems, so Swift6-generated code for operations with many query parameters keeps hitting the same 'expression too complex' compile-time blow-up this PR fixes. Either apply the same annotation to the Swift6 template (using the Prompt for AI agents |
||
| let localVariableUrlComponents = URLComponents(string: localVariableURLString){{/hasQueryParams}} | ||
|
|
||
| let localVariableNillableHeaders: [String: Any?] = [{{^headerParams}}{{^hasFormParams}}{{^hasConsumes}} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: When an operation has a query parameter named
localVariableQueryParameters, this declaration collides with the generated method parameter and makes the Swift client fail to compile. Generate a collision-free local name or scope the typed dictionary separately.Prompt for AI agents