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 Stencil Templating engine to create service files #153

Merged
merged 23 commits into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
393adcd
Use Stencil for generating AWS service source files
adam-fowler Jul 11, 2019
44e5f70
Added newline at end of all service files
adam-fowler Jul 11, 2019
be9a80b
Comments are output as arrays
adam-fowler Jul 11, 2019
7112e8e
Update ordering of variables, so I can replicate with stencil templates
adam-fowler Jul 11, 2019
6f7f327
Stencil version of files are now almost 99.9999% the same
adam-fowler Jul 11, 2019
eaa0b1e
Formatting changes to service files
adam-fowler Jul 11, 2019
2fddc0e
typo
adam-fowler Jul 11, 2019
5f49914
Remove deprecated member variables
adam-fowler Jul 11, 2019
a016fbc
Flag deprecated API calls
adam-fowler Jul 11, 2019
900a818
Removed old code generation code, tidied up
adam-fowler Jul 12, 2019
f373013
Use context in stencil include to simplify struct and enum templates
adam-fowler Jul 12, 2019
1dc4a1f
Merge branch 'master' into stencil
adam-fowler Jul 17, 2019
d8f3a54
Rebuilt files
adam-fowler Jul 17, 2019
de06734
Use structures instead of dictionaries to store contexts
adam-fowler Jul 17, 2019
bad4126
Removed dependency on aws-sdk-swift-core
adam-fowler Jul 17, 2019
ed2a213
Merge branch 'master' into stencil
adam-fowler Jul 29, 2019
27d5ec6
Output _xmlNamespace variable
adam-fowler Jul 29, 2019
de138e5
Update tests to include xmlNamespaces
adam-fowler Jul 29, 2019
68802a5
Cleaned up stencil templates
adam-fowler Jul 31, 2019
197d93e
syntax changes
adam-fowler Aug 7, 2019
d4cbde8
Added regions to BucketLocationConstraint
adam-fowler Aug 13, 2019
7457913
Stop partition endpoint overwriting region endpoint
adam-fowler Aug 13, 2019
ba0cded
Use the version of stencil forked into swift-aws
adam-fowler Aug 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
64 changes: 14 additions & 50 deletions CodeGenerator/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,39 @@
"object": {
"pins": [
{
"package": "AWSSDKSwiftCore",
"repositoryURL": "https://github.com/swift-aws/aws-sdk-swift-core.git",
"state": {
"branch": "master",
"revision": "fe381ab45774eab36ca5a87953d0cd0038bc4947",
"version": null
}
},
{
"package": "HypertextApplicationLanguage",
"repositoryURL": "https://github.com/Yasumoto/HypertextApplicationLanguage.git",
"state": {
"branch": null,
"revision": "2302002502fe573494577cc6e8df686e385519f8",
"version": "1.1.0"
}
},
{
"package": "INIParser",
"repositoryURL": "https://github.com/PerfectlySoft/Perfect-INIParser.git",
"state": {
"branch": null,
"revision": "0952aac9ca54324ff25191569fd9c48eec424772",
"version": "3.0.2"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "ba7970fe396e8198b84c6c1b44b38a1d4e2eb6bd",
"version": "1.14.1"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "0f3999f3e3c359cc74480c292644c3419e44a12f",
"version": "1.4.0"
"revision": "73f8e9dca9b7a3078cb79128217dc8f2e585a511",
"version": "1.0.0"
}
},
{
"package": "swift-nio-ssl-support",
"repositoryURL": "https://github.com/apple/swift-nio-ssl-support.git",
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "c02eec4e0e6d351cd092938cf44195a8e669f555",
"version": "1.0.0"
"revision": "f14ff47f45642aa5703900980b014c2e9394b6e5",
"version": "0.9.0"
}
},
{
"package": "swift-nio-zlib-support",
"repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git",
"package": "Stencil",
"repositoryURL": "https://github.com/swift-aws/Stencil.git",
"state": {
"branch": null,
"revision": "37760e9a52030bb9011972c5213c3350fa9d41fd",
"version": "1.0.0"
"revision": "3fff29f0140dcbabae6b5966ba99322dd169fe95",
"version": "0.13.2"
}
},
{
"package": "SwiftyJSON",
"repositoryURL": "https://github.com/IBM-Swift/SwiftyJSON.git",
"state": {
"branch": null,
"revision": "f2612ea3ac29996ae9601bdcb00cc1c29e26f104",
"version": "17.0.4"
"revision": "f9b4754017cfad4701f0838b2e507b442eaca70a",
"version": "17.0.5"
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions CodeGenerator/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ let package = Package(
.executable(name: "aws-sdk-swift-codegen", targets: ["CodeGenerator"])
],
dependencies: [
.package(url: "https://github.com/swift-aws/aws-sdk-swift-core.git", .branch("master")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So awesome 👏

.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", .upToNextMajor(from: "17.0.2"))
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", .upToNextMajor(from: "17.0.2")),
.package(url: "https://github.com/swift-aws/Stencil.git", .upToNextMajor(from: "0.13.2"))
],
targets: [
.target(name: "CodeGenerator", dependencies: ["AWSSDKSwiftCore", "SwiftyJSON"])
.target(name: "CodeGenerator", dependencies: ["SwiftyJSON", "Stencil"])
]
)
27 changes: 22 additions & 5 deletions CodeGenerator/Sources/CodeGenerator/AWSService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation
import SwiftyJSON
import AWSSDKSwiftCore

enum AWSServiceError: Error {
case eventStreamingCodeGenerationsAreUnsupported
Expand Down Expand Up @@ -68,6 +67,9 @@ struct AWSService {
endpoint["endpoints"].dictionaryValue.forEach {
if let hostname = $0.value["hostname"].string {
endpointMap[$0.key] = hostname
} else if partitionEndpoint != nil {
// if there is a partition endpoint, then default this regions endpoint to ensure partition endpoint doesn't override it. Only an issue for S3 at the moment.
endpointMap[$0.key] = "\(endpointPrefix).\($0.key).amazonaws.com"
}
}
return endpointMap
Expand Down Expand Up @@ -133,7 +135,10 @@ struct AWSService {
structure[_struct["shape"].stringValue] = try shapeType(from: shapeJSON, level: level+1)
}

let members: [Member] = try json["members"].dictionaryValue.map { name, memberJSON in
let members: [Member] = try json["members"].dictionaryValue.compactMap { name, memberJSON in
if memberJSON["deprecated"].bool == true {
return nil
}
let name = name
let memberDict = try JSONSerialization.jsonObject(with: memberJSON.rawData(), options: []) as? [String: Any] ?? [:]
let shapeName = memberJSON["shape"].stringValue
Expand Down Expand Up @@ -182,9 +187,11 @@ struct AWSService {
xmlNamespace: XMLNamespace(dictionary: memberDict),
isStreaming: memberJSON["streaming"].bool ?? false
)
}.sorted{ $0.name < $1.name }
}.sorted{ $0.name.lowercased() < $1.name.lowercased() }

let shape = StructureShape(members: members, payload: json["payload"].string)
let payloadMember = members.first(where:{$0.name == json["payload"].string})
let xmlNamespace = payloadMember?.xmlNamespace?.attributeMap["uri"] as? String
let shape = StructureShape(members: members, payload: json["payload"].string, xmlNamespace: xmlNamespace)
type = .structure(shape)

case "map":
Expand Down Expand Up @@ -278,6 +285,15 @@ struct AWSService {
}
}

var deprecatedMessage : String? = nil
if json["deprecated"].bool == true {
if let message = json["deprecatedMessage"].string {
deprecatedMessage = message
} else {
deprecatedMessage = "\(json["name"].stringValue) is deprecated."
}
}

var inputShape: Shape?
if let inputShapeName = json["input"]["shape"].string {
if let index = shapes.index(where: { inputShapeName == $0.name }) {
Expand All @@ -297,7 +313,8 @@ struct AWSService {
httpMethod: json["http"]["method"].stringValue,
path: json["http"]["requestUri"].stringValue,
inputShape: inputShape,
outputShape: outputShape
outputShape: outputShape,
deprecatedMessage: deprecatedMessage
)

operations.append(operation)
Expand Down
Loading