|
@@ -117,5 +117,27 @@ class Generator {
|
|
|
printServer()
|
|
printServer()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ println()
|
|
|
|
|
+ printProtoBufExtensions()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ internal func printProtoBufExtensions() {
|
|
|
|
|
+ var writtenValues = Set<String>()
|
|
|
|
|
+ println("/// Provides conformance to `GRPCPayload` for the request and response messages")
|
|
|
|
|
+ for service in file.services {
|
|
|
|
|
+ self.service = service
|
|
|
|
|
+ for method in service.methods {
|
|
|
|
|
+ self.method = method
|
|
|
|
|
+ printExtension(for: methodInputName, typesSeen: &writtenValues)
|
|
|
|
|
+ printExtension(for: methodOutputName, typesSeen: &writtenValues)
|
|
|
|
|
+ }
|
|
|
|
|
+ println()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func printExtension(for messageType: String, typesSeen: inout Set<String>) {
|
|
|
|
|
+ guard !typesSeen.contains(messageType) else { return }
|
|
|
|
|
+ println("extension \(messageType): GRPCProtobufPayload {}")
|
|
|
|
|
+ typesSeen.insert(messageType)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|