Skip to content

Commit

Permalink
Merge pull request #17 from amzn/dictionary_fix
Browse files Browse the repository at this point in the history
Fix generation for dictionaries with built in value types.
  • Loading branch information
tachyonics authored May 1, 2020
2 parents 6f0ba75 + 178af47 commit b7de9a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ internal extension ServiceModelCodeGenerator {
isRequired: true)

let fullKeyTypeName = keyTypeName.isBuiltinType ? keyTypeName : "\(baseName)Model.\(keyTypeName)"
let fullValueTypeName = valueTypeName.isBuiltinType ? valueTypeName : "\(baseName)Model.\(valueTypeName)"

let capitalizedVariableName = variableName.lowerToUpperCamelCase
let fieldType = "[\(fullKeyTypeName): \(fullValueTypeName)]\(optionalInfix)"

// if there is actually conversion on each element
if conversionDetails.conversion != "entry" {
if conversionDetails.conversion != "entry" && !valueTypeName.isBuiltinType {
let fullValueTypeName = "\(baseName)Model.\(valueTypeName)"

let capitalizedVariableName = variableName.lowerToUpperCamelCase
let fieldType = "[\(fullKeyTypeName): \(fullValueTypeName)]\(optionalInfix)"

var setupBuilder =
"let converted\(capitalizedVariableName): \(fieldType) = \(failPostfix)\(variableName)\(optionalInfix).mapValues { entry in\n"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ public extension ServiceModelCodeGenerator {

shapeCategory = .collectionType("\(collectionAssociatedType) == [\(keyTypeName): \(valueTypeName)]")
}
} else if fieldName.isBuiltinType {
shapeCategory = .builtInType(fieldName)
} else {
shapeCategory = .protocolType("\(typeName)Shape")
}
Expand Down

0 comments on commit b7de9a4

Please sign in to comment.