Update capabilities to be expressible by Boolean literals (#16)
* Conform Server.Capabilities types to ExpressibleByBooleanLiteral * Conform Client.Capabilities types to ExpressibleByBooleanLiteral * Use Boolean literatls for capabilities in tests * Update README
This commit is contained in:
parent
4ed52bc2c3
commit
3e628db6d8
4 changed files with 46 additions and 8 deletions
|
|
@ -51,11 +51,9 @@ let server = Server(
|
||||||
name: "MyServer",
|
name: "MyServer",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
capabilities: .init(
|
capabilities: .init(
|
||||||
prompts: .init(),
|
prompts: true,
|
||||||
resources: .init(
|
resources: true,
|
||||||
subscribe: true
|
tools: true
|
||||||
),
|
|
||||||
tools: .init()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -408,3 +408,17 @@ public actor Client {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - ExpressibleByBooleanLiteral
|
||||||
|
|
||||||
|
extension Client.Capabilities.Roots: ExpressibleByBooleanLiteral {
|
||||||
|
public init(booleanLiteral value: Bool) {
|
||||||
|
self.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Client.Capabilities.Sampling: ExpressibleByBooleanLiteral {
|
||||||
|
public init(booleanLiteral value: Bool) {
|
||||||
|
self.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -408,3 +408,29 @@ public actor Server {
|
||||||
self.isInitialized = true
|
self.isInitialized = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - ExpressibleByBooleanLiteral
|
||||||
|
|
||||||
|
extension Server.Capabilities.Logging: ExpressibleByBooleanLiteral {
|
||||||
|
public init(booleanLiteral value: Bool) {
|
||||||
|
self.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Server.Capabilities.Prompts: ExpressibleByBooleanLiteral {
|
||||||
|
public init(booleanLiteral value: Bool) {
|
||||||
|
self.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Server.Capabilities.Resources: ExpressibleByBooleanLiteral {
|
||||||
|
public init(booleanLiteral value: Bool) {
|
||||||
|
self.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Server.Capabilities.Tools: ExpressibleByBooleanLiteral {
|
||||||
|
public init(booleanLiteral value: Bool) {
|
||||||
|
self.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ struct RoundtripTests {
|
||||||
name: "TestServer",
|
name: "TestServer",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
capabilities: .init(
|
capabilities: .init(
|
||||||
prompts: .init(),
|
prompts: true,
|
||||||
resources: .init(),
|
resources: true,
|
||||||
tools: .init()
|
tools: true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
await server.withMethodHandler(ListTools.self) { _ in
|
await server.withMethodHandler(ListTools.self) { _ in
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue