Skip to content
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

Generic Static Accessors in Swift 5.5 #3499

Merged
merged 12 commits into from
Oct 3, 2021
Merged

Conversation

jshier
Copy link
Contributor

@jshier jshier commented Sep 24, 2021

Goals ⚽

This PR makes various protocol values available as static members so they can be used in generic contexts using the new Swift 5.5 syntax. This enables some nicer call sites:

Previously

AF.request("https://httpbin.org/post",
            method: .post,
            parameters: Value(),
            encoder: JSONParameterEncoder(),
            interceptor: RetryPolicy())
    .response(responseSerializer: DecodableResponseSerializer<TestResponse>()) { response in
         debugPrint(response)
    }

Now

AF.request("https://httpbin.org/post",
           method: .post,
           parameters: Value(),
           encoder: .json,
           interceptor: .retryPolicy)
    .response(responseSerializer: .decodable(of: TestResponse.self)) { response in
        debugPrint(response)
    }

These improvements grow the more customized protocol values are used.

Testing Details 🔍

Added tests for accessing, but not using, these static values, as the types themselves are already tested.

@jshier jshier merged commit f3e26fb into master Oct 3, 2021
@jshier jshier deleted the feature/static-accessors branch October 3, 2021 01:00
@jshier jshier added this to the 5.5.0 milestone Dec 13, 2021
jshier added a commit that referenced this pull request Jan 15, 2022
* Add CachedResponseHandler static accessors.

* Add ParameterEncoder static accessors.

* Add RedirectHandler static accessors.

* Add RequestInterceptor static accessors.

* Add ResponseSerializer static accessors.

* Add ServerTrust static accessors.

* Formatting.

* Fix compilation.

* Add overloads to make members visible.

* Add iOS 15 testing.

* Update expected user agent test.

* Add default static accessors.
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.

None yet

1 participant