Skip to content

Conversation

@x-sheep
Copy link
Contributor

@x-sheep x-sheep commented Mar 17, 2025

By no longer using Any as a type, we can assert that all parameter dictionaries are Sendable. This allows upgrading Alamofire to the latest version.

Fixes #20398

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11) @dydus0x14 (2023/06)

@x-sheep x-sheep closed this Mar 17, 2025
@x-sheep x-sheep reopened this Mar 17, 2025
@x-sheep
Copy link
Contributor Author

x-sheep commented Mar 17, 2025

I don't know why the test is failing. It seems the test output itself is broken?

/Users/vagrant/.asdf/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/xcpretty-0.4.0/lib/xcpretty/parser.rb:366:in `parse': uninitialized constant XCPretty::Parser::ERB (NameError)

        formatter.format_failing_test($2, $3, ERB::Util.html_escape($4), $1)
                                              ^^^
	from /Users/vagrant/.asdf/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/xcpretty-0.4.0/lib/xcpretty/formatters/formatter.rb:88:in `pretty_format'

@4brunu
Copy link
Contributor

4brunu commented Mar 17, 2025

Hi @x-sheep, thanks for creating this PR, this is a nice contribution.

By building this locally I got the following errors:

/Users/OpenAPI/Developer/Github/openapi-generator/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift:707:1: error: instance method 'encode(request:with:)' has different argument labels from those required by protocol 'ParameterEncoding' ('encode(_:with:)')
432 | 
433 | public protocol ParameterEncoding {
434 |     func encode(_ urlRequest: URLRequest, with parameters: [String: any Sendable]?) throws -> URLRequest
    |          `- note: requirement 'encode(_:with:)' declared here
435 | }
436 | 
    :
705 | }
706 | 
707 | extension JSONDataEncoding: ParameterEncoding {}
    | `- error: instance method 'encode(request:with:)' has different argument labels from those required by protocol 'ParameterEncoding' ('encode(_:with:)')
708 | 
709 | public enum OpenAPIInterceptorRetry {

/Users/OpenAPI/Developer/Github/openapi-generator/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/JSONDataEncoding.swift:30:17: note: 'encode(request:with:)' declared here
28 |     ///
29 |     /// - returns: The encoded request.
30 |     public func encode(request: URLRequest, with parameters: [String: any Sendable]?) -> URLRequest {
   |                 `- note: 'encode(request:with:)' declared here
31 |         var urlRequest = request
32 | 
/Users/OpenAPI/Developer/Github/openapi-generator/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/URLSessionImplementations.swift:707:1: error: instance method 'encode(request:with:)' has different argument labels from those required by protocol 'ParameterEncoding' ('encode(_:with:)')
432 | 
433 | public protocol ParameterEncoding {
434 |     func encode(_ urlRequest: URLRequest, with parameters: [String: any Sendable]?) throws -> URLRequest
    |          `- note: requirement 'encode(_:with:)' declared here
435 | }
436 | 
    :
705 | }
706 | 
707 | extension JSONDataEncoding: ParameterEncoding {}
    | `- error: instance method 'encode(request:with:)' has different argument labels from those required by protocol 'ParameterEncoding' ('encode(_:with:)')
708 | 
709 | public enum OpenAPIInterceptorRetry {

/Users/OpenAPI/Developer/Github/openapi-generator/samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/JSONDataEncoding.swift:30:17: note: 'encode(request:with:)' declared here
28 |     ///
29 |     /// - returns: The encoded request.
30 |     public func encode(request: URLRequest, with parameters: [String: any Sendable]?) -> URLRequest {
   |                 `- note: 'encode(request:with:)' declared here
31 |         var urlRequest = request
32 | 
[3/3] Compiling PetstoreClient URLSessionImplementations.swift

@4brunu
Copy link
Contributor

4brunu commented Mar 17, 2025

Since we are having some problems with the server returning some errors, you can try to build the sample projects locally by commenting the following lines (please don't commit this change).

# example project with unit tests
(cd $DIRECTORY/alamofireLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)
(cd $DIRECTORY/apiNonStaticMethod/SwaggerClientTests/ && ./run_xcodebuild.sh)
(cd $DIRECTORY/asyncAwaitLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)
# (cd $DIRECTORY/combineLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)
(cd $DIRECTORY/combineDeferredLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)
(cd $DIRECTORY/default/SwaggerClientTests/ && ./run_xcodebuild.sh)
# (cd $DIRECTORY/promisekitLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)
(cd $DIRECTORY/rxswiftLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)
(cd $DIRECTORY/urlsessionLibrary/SwaggerClientTests/ && ./run_xcodebuild.sh)

And then you can run the following command in the terminal to build all the swift sample projects.
sh swift6_test_all.sh

@4brunu
Copy link
Contributor

4brunu commented Mar 17, 2025

Now it builds locally.
Looks good to me 👍
Thanks for this awesome contribution.
We are open to contributions.
Do you see other areas where the Swift 6 generator needs improvement?

@4brunu 4brunu merged commit 31c1a86 into OpenAPITools:master Mar 17, 2025
15 of 16 checks passed
@x-sheep x-sheep deleted the swift6-querystringencode branch March 18, 2025 08:32
@wing328
Copy link
Member

wing328 commented Mar 18, 2025

@x-sheep thanks for the PR

when you've time, can you please PM me via Slack for a quick chat?

https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][Swift6] Numerous compilation issues with Swift 6 generator + Alamofire 5.10.x

3 participants