Skip to content

Commit

Permalink
Add test for generated server register handlers without operations
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurcro committed Aug 17, 2023
1 parent 2faf804 commit 49b3115
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct ServerFileTranslator: FileTranslator {
}
let serverMethodDecls = serverMethodDeclPairs.map(\.functionDecl)

// To avoid an used variable warning, we add the server variable declaration
// To avoid an unused variable warning, we add the server variable declaration
// and server method register calls to the body of the register handler declaration
// only when there is at least one registration call.
if !serverMethodDeclPairs.isEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,23 @@ final class SnippetBasedReferenceTests: XCTestCase {
)
}

func testServerRegisterHandlers_noOperation() throws {
try self.assertServerRegisterHandlers(
"""
{}
""",
"""
public func registerHandlers(
on transport: any ServerTransport,
serverURL: URL = .defaultOpenAPIServerURL,
configuration: Configuration = .init(),
middlewares: [any ServerMiddleware] = []
) throws {
}
"""
)
}

func testPathWithPathItemReference() throws {
XCTAssertThrowsError(
try self.assertPathsTranslation(
Expand Down

0 comments on commit 49b3115

Please sign in to comment.