Skip to content

Commit

Permalink
Merge pull request #13 from amzn/smoke_framework_2_generation
Browse files Browse the repository at this point in the history
Add support for SmokeFramework 2 generation.
  • Loading branch information
tachyonics authored Mar 12, 2020
2 parents 739e3d2 + f42ae27 commit 7bea0be
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
21 changes: 20 additions & 1 deletion Sources/ServiceModelCodeGeneration/ModelErrorsDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,26 @@ public protocol ModelErrorsDelegate {
*/
func errorTypeAdditionalErrorDecodeStatementsGenerator(fileBuilder: FileBuilder,
errorTypes: [ErrorType])


/**
Generator for the error type additional encode cases using the error identity.
- Parameters:
- fileBuilder: The FileBuilder to output to.
- errorTypes: The sorted list of error types.
*/
func errorTypeAdditionalErrorEncodeStatementsGenerator(fileBuilder: FileBuilder,
errorTypes: [ErrorType])

/**
Generator for the error type additional description cases.
- Parameters:
- fileBuilder: The FileBuilder to output to.
- errorTypes: The sorted list of error types.
*/
func errorTypeAdditionalDescriptionCases(fileBuilder: FileBuilder,
errorTypes: [ErrorType])
}

public extension ModelErrorsDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public extension ServiceModelCodeGenerator {
// add code to get the identity variable from the delegate
let identityVariable = delegate.errorTypeIdentityGenerator(
fileBuilder: fileBuilder,
codingErrorUnknownError: "\(baseName)CodingError.unknownError")
codingErrorUnknownError: "\(baseName)Error.unknownError")

fileBuilder.appendEmptyLine()
fileBuilder.appendLine("switch \(identityVariable) {")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public extension ServiceModelCodeGenerator {
return \(internalName)Identity
""")
}
delegate.errorTypeAdditionalDescriptionCases(fileBuilder: fileBuilder, errorTypes: sortedErrors)
fileBuilder.decIndent()
fileBuilder.decIndent()

Expand Down Expand Up @@ -190,6 +191,8 @@ public extension ServiceModelCodeGenerator {
try details.encode(to: encoder)
""")
}
delegate.errorTypeAdditionalErrorEncodeStatementsGenerator(fileBuilder: fileBuilder,
errorTypes: sortedErrors)
fileBuilder.decIndent()
fileBuilder.decIndent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public extension ServiceModelCodeGenerator {
//
import Foundation
import SmokeAWSCore
import SmokeHTTPClient
import SmokeAWSHttp
import \(baseName)Model
""")
Expand All @@ -55,7 +55,7 @@ public extension ServiceModelCodeGenerator {
/**
Operation reporting for the \(baseName)Model.
*/
public struct \(baseName)InvocationsReporting<InvocationReportingType: SmokeAWSInvocationReporting> {
public struct \(baseName)InvocationsReporting<InvocationReportingType: HTTPClientCoreInvocationReporting> {
""")

let sortedOperations = model.operationDescriptions.sorted { (left, right) in left.key < right.key }
Expand Down

0 comments on commit 7bea0be

Please sign in to comment.