smithy-lang/smithy-swift

ClientRuntime.URLQueryItem typealias

Closed this issue · 1 comments

Describe the bug

ClientRuntime.URLQueryItem is typealiased to MyURLQueryItem in 0.20.0. It was previously Foundation.URLQueryItem.

If ClientRuntime needs its own (non foundation) URLQueryItem type, can we please change it to a more reasonable name?

Expected Behavior

ClientRuntime.URLQueryItem ideally be typealiased to Foundation.URLQueryItem or, if it needs to be its own type, a more descriptive type name.

Current Behavior

https://github.com/awslabs/smithy-swift/blob/0.20.0/Sources/ClientRuntime/PrimitiveTypeExtensions/URLQueryItem%2BExtensions.swift#L6-L16

Reproduction Steps

let queryItems: [URLQueryItem] = [...]
let requestBuilder = SdkHttpRequestBuilder()
   .withHost(host)
   .withPath(url.path)
   .withQueryItems(queryItems) //  ❌ Cannot convert value of type '[Foundation.URLQueryItem]' to expected argument type '[ClientRuntime.URLQueryItem]' (aka 'Swift.Array<ClientRuntime.MyURLQueryItem>')
   .withMethod(httpMethod)
   .withPort(443)
   .withProtocol(.https)
   // ...

It also results in errors where a (Foundation) URLQueryItem is instantiated in the same file as a ClientRuntime import.

import Foundation
import ClientRuntime

_ = URLQueryItem(name: name, value: value) // ❌ Ambiguous use of 'init(name:value:)'

Possible Solution

No response

Additional Information/Context

No response

AWS SWIFT SDK version used

0.17.0

Compiler and Version used

N/A

Operating System and version

N/A

@atierian I might just abolish that typealias altogether; I'm not sure of what the origin was, and I just reassigned the ClientRuntime.URLQueryItem typealias (it used to assign Foundation.URLQueryItem, I changed it to MyQueryItem) when I fixed the encoding issue for you a few days back.

But then I also need a better name than MyURLQueryItem 🤔