Skip to content

Commit

Permalink
Add repo URL to generated file preamble
Browse files Browse the repository at this point in the history
I am soon going to distribute json2swift as a binary, instead of having devs build the tool from source, so I’m adding a link to the tool’s GitHub repository. This will help people know where the tool came from, how to submit bug reports, request features, etc.
  • Loading branch information
Josh Smith committed Nov 5, 2016
1 parent 5292d31 commit 162626b
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions json2swift/swift-code-generation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ struct SwiftCodeGenerator {
/// This method is used when only one Swift file is being generated.
static func generateCodeWithJSONUtilities(for swiftStruct: SwiftStruct) -> String {
return [
"// This file was generated by json2swift.",
"",
"import Foundation",
"",
preamble,
"//",
"// MARK: - Data Model",
"//",
Expand All @@ -31,24 +28,24 @@ struct SwiftCodeGenerator {
/// This method is used when multiple Swift files are being generated.
static func generateCode(for swiftStruct: SwiftStruct) -> String {
return [
"// This file was generated by json2swift.",
"",
"import Foundation",
"",
preamble,
swiftStruct.toSwiftCode(),
""].joined(separator: "\n")
}

/// This method is used to only create the JSON utility code once when multiple Swift files are being generated.
static func generateJSONUtilities() -> String {
return [
"// This file was generated by json2swift.",
"",
"import Foundation",
"",
preamble,
jsonUtilitiesTemplate,
""].joined(separator: "\n")
}

private static let preamble = [
"// This file was generated by json2swift. https://github.com/ijoshsmith/json2swift",
"",
"import Foundation",
""].joined(separator: "\n")
}


Expand Down

0 comments on commit 162626b

Please sign in to comment.