smithy-lang/smithy-swift

Improve URL Query Item creation

Closed this issue · 1 comments

epau commented

When implementing #468 it became clear that there is much room for improvement in our handling of query item creation.
Currently much logic resides in the codegen flow and ideally we'd move as much logic as possible to native swift code.

A rough idea is to define an item description that properly describes a query item and then define a factory that converts item descriptions to url query items using our business logic.

struct ItemDescription {
    let name: String
    let value: String? 
    let isRequired: Bool
}

struct QueryItemFactory {
    static func makeItems(_ descriptions: [ItemDescription]) throws -> [URLQueryItem] {
        descriptions.forEach { 
             // if required and value is nil then throw error
             // if value is nil then don't create a query item 
             // else -> create a query item with the name and value pair
        }
    }
}
epau commented

Closing in favor of awslabs/aws-sdk-swift#714