diff --git a/Sources/GRPCCodeGen/Internal/Translator/IDLToStructuredSwiftTranslator.swift b/Sources/GRPCCodeGen/Internal/Translator/IDLToStructuredSwiftTranslator.swift index 612768cdd..eccc65ba3 100644 --- a/Sources/GRPCCodeGen/Internal/Translator/IDLToStructuredSwiftTranslator.swift +++ b/Sources/GRPCCodeGen/Internal/Translator/IDLToStructuredSwiftTranslator.swift @@ -74,9 +74,9 @@ package struct IDLToStructuredSwiftTranslator: Translator { } } - let imports: [ImportDescription] + let imports: [ImportDescription]? if codeGenerationRequest.services.isEmpty { - imports = [] + imports = nil codeBlocks.append( CodeBlock(comment: .inline("This file contained no services.")) ) diff --git a/Tests/GRPCCodeGenTests/Internal/Translator/IDLToStructuredSwiftTranslatorSnippetBasedTests.swift b/Tests/GRPCCodeGenTests/Internal/Translator/IDLToStructuredSwiftTranslatorSnippetBasedTests.swift index d30fe8954..8f4509b50 100644 --- a/Tests/GRPCCodeGenTests/Internal/Translator/IDLToStructuredSwiftTranslatorSnippetBasedTests.swift +++ b/Tests/GRPCCodeGenTests/Internal/Translator/IDLToStructuredSwiftTranslatorSnippetBasedTests.swift @@ -145,7 +145,6 @@ final class IDLToStructuredSwiftTranslatorSnippetBasedTests: XCTestCase { """ /// Some really exciting license header 2023. - // This file contained no services. """ try self.assertIDLToStructuredSwiftTranslation(