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

Use swift-mustache 2.0 beta #80

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.8
import PackageDescription

let package = Package(
Expand All @@ -11,7 +11,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/soto-project/soto-smithy.git", from: "0.3.7"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
.package(url: "https://github.com/hummingbird-project/swift-mustache.git", from: "1.0.3"),
.package(url: "https://github.com/hummingbird-project/swift-mustache.git", from: "2.0.0-beta"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
],
targets: [
Expand All @@ -28,7 +28,7 @@ let package = Package(
dependencies: [
.product(name: "SotoSmithy", package: "soto-smithy"),
.product(name: "SotoSmithyAWS", package: "soto-smithy"),
.product(name: "HummingbirdMustache", package: "swift-mustache"),
.product(name: "Mustache", package: "swift-mustache"),
.product(name: "Logging", package: "swift-log")
]
),
Expand Down
11 changes: 5 additions & 6 deletions Sources/SotoCodeGeneratorLib/AwsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===//

import Foundation
import HummingbirdMustache
import Logging
import Mustache
import SotoSmithy
import SotoSmithyAWS

Expand Down Expand Up @@ -360,7 +360,6 @@ struct AwsService {
TreeHashMiddleware(header: \"x-amz-sha256-tree-hash\")
}
"""

case "S3":
return "S3Middleware()"
default:
Expand Down Expand Up @@ -568,7 +567,7 @@ struct AwsService {
}
endpointValue = endpointValue.applyingPartitionDefaults(partition.defaults)
guard let variants = endpointValue.variants else { return }
variants.forEach { variant in
for variant in variants {
let variantString = variant.tags
.map { ".\($0)" }
.sorted()
Expand All @@ -577,7 +576,7 @@ struct AwsService {
guard let dnsSuffix = getDefaultValue(partition: partition, service: service, getValue: { defaults in
return defaults.variants?.first(where: { $0.tags == variant.tags })?.dnsSuffix
}) else {
return
continue
}
if variantEndpoints[variantString] == nil {
variantEndpoints[variantString] = .init()
Expand Down Expand Up @@ -713,7 +712,7 @@ extension AwsService {
}

struct MemberCodableContext {
internal init(
init(
inHeader: String? = nil,
inQuery: String? = nil,
inURI: String? = nil,
Expand Down Expand Up @@ -770,7 +769,7 @@ extension AwsService {
let location: String?
}

class ValidationContext: HBMustacheTransformable {
class ValidationContext: MustacheTransformable {
let name: String
let shape: Bool
let required: Bool
Expand Down
4 changes: 2 additions & 2 deletions Sources/SotoCodeGeneratorLib/SotoCodeGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===//

import Foundation
import HummingbirdMustache
import Logging
import Mustache
import SotoSmithy
import SotoSmithyAWS

Expand All @@ -39,7 +39,7 @@ public struct SotoCodeGen {
}

let command: SotoCodeGenCommand
let library: HBMustacheLibrary
let library: MustacheLibrary
let logger: Logging.Logger

public init(command: SotoCodeGenCommand) throws {
Expand Down
8 changes: 4 additions & 4 deletions Sources/SotoCodeGeneratorLib/Templates/Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import HummingbirdMustache
import Mustache

enum Templates {
static var values: [String: String] = [
Expand All @@ -28,10 +28,10 @@ enum Templates {
"waiters": waiterTemplate,
]

static func createLibrary() throws -> HBMustacheLibrary {
let library = HBMustacheLibrary()
static func createLibrary() throws -> MustacheLibrary {
var library = MustacheLibrary()
for v in self.values {
let template = try HBMustacheTemplate(string: v.value)
let template = try MustacheTemplate(string: v.value)
library.register(template, named: v.key)
}
return library
Expand Down
12 changes: 8 additions & 4 deletions Sources/SotoCodeGeneratorLib/Templates/struct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ extension Templates {
let container = try decoder.container(keyedBy: CodingKeys.self)
{{/empty(codingKeys)}}
{{/shapeCoding.singleValueContainer}}
{{#members}}{{#memberCoding}}
{{#members}}
{{#memberCoding}}
{{#isCodable}}
self.{{variable}} = try container.decode{{^propertyWrapper}}{{^required}}IfPresent{{/required}}{{/propertyWrapper}}({{codableType}}.self, forKey: .{{variable}}){{#propertyWrapper}}.wrappedValue{{/propertyWrapper}}
{{/isCodable}}
Expand All @@ -120,7 +121,8 @@ extension Templates {
{{#isStatusCode}}
self.{{variable}} = response.decodeStatus()
{{/isStatusCode}}
{{/memberCoding}}{{/members}}
{{/memberCoding}}
{{/members}}
}
{{/shapeCoding.requiresDecodeInit}}
{{#shapeCoding.requiresEncode}}
Expand All @@ -140,7 +142,8 @@ extension Templates {
_ = encoder.container(keyedBy: CodingKeys.self)
{{/empty(codingKeys)}}
{{/shapeCoding.singleValueContainer}}
{{#members}}{{#memberCoding}}
{{#members}}
{{#memberCoding}}
{{#isCodable}}
try container.encode{{^required}}IfPresent{{/required}}(self.{{variable}}, forKey: .{{variable}})
{{/isCodable}}
Expand All @@ -162,7 +165,8 @@ extension Templates {
{{#isPayload}}
try container.encode(self.{{variable}})
{{/isPayload}}
{{/memberCoding}}{{/members}}
{{/memberCoding}}
{{/members}}
}
{{/shapeCoding.requiresEncode}}
{{! validate() function }}
Expand Down