Skip to content

Commit 69eb1a2

Browse files
authored
Disable "respectsExistingLineBreaks" in .swift-format for more consistent styling (#346)
### Motivation - Fixes #230 ### Modifications - Disable respectsExistingLineBreaks .swift-format rule and address changes requested ### Result - One of the .swift-format rules will be disabled ### Test Plan - Run Tests
1 parent f071608 commit 69eb1a2

File tree

136 files changed

+2477
-7813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2477
-7813
lines changed

.swift-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"lineLength" : 120,
1515
"maximumBlankLines" : 1,
1616
"prioritizeKeepingFunctionOutputTogether" : false,
17-
"respectsExistingLineBreaks" : true,
17+
"respectsExistingLineBreaks" : false,
1818
"rules" : {
1919
"AllPublicDeclarationsHaveDocumentation" : true,
2020
"AlwaysUseLowerCamelCase" : false,

Examples/GreetingService/Package.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import PackageDescription
1616

1717
let package = Package(
1818
name: "GreetingService",
19-
platforms: [
20-
.macOS(.v13)
21-
],
19+
platforms: [.macOS(.v13)],
2220
dependencies: [
2321
.package(url: "https://github.com/apple/swift-openapi-generator", .upToNextMinor(from: "0.3.0")),
2422
.package(url: "https://github.com/apple/swift-openapi-runtime", .upToNextMinor(from: "0.3.0")),
@@ -33,16 +31,11 @@ let package = Package(
3331
.product(name: "OpenAPIVapor", package: "swift-openapi-vapor"),
3432
.product(name: "Vapor", package: "vapor"),
3533
],
36-
plugins: [
37-
.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")
38-
]
34+
plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")]
3935
),
4036
.testTarget(
4137
name: "GreetingServiceMockTests",
42-
dependencies: [
43-
"GreetingService",
44-
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
45-
]
38+
dependencies: ["GreetingService", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")]
4639
),
4740
]
4841
)

Examples/GreetingService/Sources/GreetingService/GreetingService.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import Vapor
1919
struct Handler: APIProtocol {
2020

2121
// This function is a protocol requirement, derived from the operation in the OpenAPI document.
22-
func getGreeting(
23-
_ input: Operations.getGreeting.Input
24-
) async throws -> Operations.getGreeting.Output {
22+
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
2523
// Extract the query parameter from the input, using generated type-safe property.
2624
let name = input.query.name ?? "Stranger"
2725

@@ -30,8 +28,7 @@ struct Handler: APIProtocol {
3028
}
3129
}
3230

33-
@main
34-
struct Main {
31+
@main struct Main {
3532
/// The entry point of the program.
3633
///
3734
/// This is where the execution of the program begins. Any code you want to run

Examples/GreetingService/Tests/GreetingServiceMockTests/MockGreetingService.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import GreetingService
1515

1616
// Mock operates on value types, and requires no concrete client or server transport.
1717
struct MockGreetingService: APIProtocol {
18-
func getGreeting(
19-
_ input: Operations.getGreeting.Input
20-
) async throws -> Operations.getGreeting.Output {
18+
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
2119
let name = input.query.name ?? "<unknown>"
2220
return .ok(.init(body: .json(.init(message: "(mock) Hello, \(name)"))))
2321
}

Examples/GreetingServiceClient/Package.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import PackageDescription
1616

1717
let package = Package(
1818
name: "GreetingServiceClient",
19-
platforms: [
20-
.macOS(.v13)
21-
],
19+
platforms: [.macOS(.v13)],
2220
dependencies: [
2321
.package(url: "https://github.com/apple/swift-openapi-generator", .upToNextMinor(from: "0.3.0")),
2422
.package(url: "https://github.com/apple/swift-openapi-runtime", .upToNextMinor(from: "0.3.0")),
@@ -31,9 +29,7 @@ let package = Package(
3129
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
3230
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
3331
],
34-
plugins: [
35-
.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")
36-
]
32+
plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")]
3733
)
3834
]
3935
)

Examples/GreetingServiceClient/Sources/GreetingServiceClient/GreetingServiceClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import OpenAPIRuntime
1515
import OpenAPIURLSession
1616

17-
@main
18-
struct GreetingServiceClient {
17+
@main struct GreetingServiceClient {
1918

2019
static func main() async throws {
2120
// Create an instance of the generated client type.
@@ -45,6 +44,7 @@ struct GreetingServiceClient {
4544

4645
// Use shorthand APIs to get an expected response or otherwise throw a runtime error.
4746
print(try await client.getGreeting().ok.body.json.message)
47+
4848
// ^ ^ ^
4949
// | | `- Throws if body did not parse as documented JSON.
5050
// | |

Examples/GreetingServiceClient/Tests/GreetingServiceMockTests/MockGreetingService.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import GreetingService
1515

1616
// Mock operates on value types, and requires no concrete client or server transport.
1717
struct MockGreetingService: APIProtocol {
18-
func getGreeting(
19-
_ input: Operations.getGreeting.Input
20-
) async throws -> Operations.getGreeting.Output {
18+
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
2119
let name = input.query.name ?? "<unknown>"
2220
return .ok(.init(body: .json(.init(message: "(mock) Hello, \(name)"))))
2321
}

IntegrationTest/Package.swift

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,11 @@ import PackageDescription
1616

1717
let package = Package(
1818
name: "swift-openapi-integration-test",
19-
platforms: [
20-
.macOS(.v13)
21-
],
19+
platforms: [.macOS(.v13)],
2220
products: [
2321
.library(
2422
name: "IntegrationTestLibrary",
25-
targets: [
26-
"Types",
27-
"Client",
28-
"Server",
29-
"MockTransportClient",
30-
"MockTransportServer",
31-
]
23+
targets: ["Types", "Client", "Server", "MockTransportClient", "MockTransportServer"]
3224
)
3325
],
3426
dependencies: [
@@ -38,70 +30,26 @@ let package = Package(
3830
targets: [
3931
.target(
4032
name: "Types",
41-
dependencies: [
42-
.product(
43-
name: "OpenAPIRuntime",
44-
package: "swift-openapi-runtime"
45-
)
46-
],
47-
plugins: [
48-
.plugin(
49-
name: "OpenAPIGenerator",
50-
package: "swift-openapi-generator"
51-
)
52-
]
33+
dependencies: [.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")],
34+
plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")]
5335
),
5436
.target(
5537
name: "Client",
56-
dependencies: [
57-
"Types",
58-
.product(
59-
name: "OpenAPIRuntime",
60-
package: "swift-openapi-runtime"
61-
),
62-
],
63-
plugins: [
64-
.plugin(
65-
name: "OpenAPIGenerator",
66-
package: "swift-openapi-generator"
67-
)
68-
]
38+
dependencies: ["Types", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")],
39+
plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")]
6940
),
7041
.target(
7142
name: "Server",
72-
dependencies: [
73-
"Types",
74-
.product(
75-
name: "OpenAPIRuntime",
76-
package: "swift-openapi-runtime"
77-
),
78-
],
79-
plugins: [
80-
.plugin(
81-
name: "OpenAPIGenerator",
82-
package: "swift-openapi-generator"
83-
)
84-
]
43+
dependencies: ["Types", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")],
44+
plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")]
8545
),
8646
.target(
8747
name: "MockTransportClient",
88-
dependencies: [
89-
"Client",
90-
.product(
91-
name: "OpenAPIRuntime",
92-
package: "swift-openapi-runtime"
93-
),
94-
]
48+
dependencies: ["Client", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")]
9549
),
9650
.target(
9751
name: "MockTransportServer",
98-
dependencies: [
99-
"Server",
100-
.product(
101-
name: "OpenAPIRuntime",
102-
package: "swift-openapi-runtime"
103-
),
104-
]
52+
dependencies: ["Server", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")]
10553
),
10654
]
10755
)

IntegrationTest/Sources/MockTransportClient/Client.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,12 @@ import Foundation
1818
import HTTPTypes
1919

2020
struct MockClientTransport: ClientTransport {
21-
func send(
22-
_ request: HTTPTypes.HTTPRequest,
23-
body: OpenAPIRuntime.HTTPBody?,
24-
baseURL: URL,
25-
operationID: String
26-
) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
27-
(HTTPTypes.HTTPResponse(status: 200), nil)
28-
}
21+
func send(_ request: HTTPTypes.HTTPRequest, body: OpenAPIRuntime.HTTPBody?, baseURL: URL, operationID: String)
22+
async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
23+
{ (HTTPTypes.HTTPResponse(status: 200), nil) }
2924
}
3025

3126
func run() async throws {
32-
let client = Client(
33-
serverURL: try Servers.server1(),
34-
transport: MockClientTransport()
35-
)
27+
let client = Client(serverURL: try Servers.server1(), transport: MockClientTransport())
3628
_ = try await client.getGreeting(.init())
3729
}

IntegrationTest/Sources/MockTransportServer/Server.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ import OpenAPIRuntime
1717
import HTTPTypes
1818

1919
actor SimpleAPIImpl: APIProtocol {
20-
func getGreeting(
21-
_ input: Operations.getGreeting.Input
22-
) async throws -> Operations.getGreeting.Output {
20+
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
2321
let message = "Hello, \(input.query.name ?? "Stranger")!"
2422
return .ok(.init(body: .json(.init(message: message))))
2523
}
@@ -30,20 +28,13 @@ class MockServerTransport: ServerTransport {
3028
HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata
3129
) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
3230

33-
func register(
34-
_ handler: @escaping Handler,
35-
method: HTTPTypes.HTTPRequest.Method,
36-
path: String
37-
) throws {
31+
func register(_ handler: @escaping Handler, method: HTTPTypes.HTTPRequest.Method, path: String) throws {
3832
// noop.
3933
}
4034
}
4135

4236
func initializeServer() throws {
4337
let handler = SimpleAPIImpl()
4438
let transport = MockServerTransport()
45-
try handler.registerHandlers(
46-
on: transport,
47-
serverURL: Servers.server1()
48-
)
39+
try handler.registerHandlers(on: transport, serverURL: Servers.server1())
4940
}

0 commit comments

Comments
 (0)