Skip to content

Commit b6c3567

Browse files
committed
Relax dependency on SwiftFormat.
1 parent 4c8ed5c commit b6c3567

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ let package = Package(
5555
// Generate Swift code
5656
.package(
5757
url: "https://github.com/apple/swift-syntax.git",
58-
from: "508.0.1"
58+
"508.0.1"..<"510.0.0"
5959
),
6060

6161
// Format Swift code
6262
.package(
6363
url: "https://github.com/apple/swift-format.git",
64-
from: "508.0.1"
64+
"508.0.1"..<"510.0.0"
6565
),
6666

6767
// General algorithms

Sources/_OpenAPIGeneratorCore/Extensions/SwiftFormat.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ extension String {
3939
assumingFileURL: nil,
4040
to: &formattedString
4141
) { diagnostic, sourceLocation in
42+
#if canImport(SwiftSyntax509)
43+
let location = "\(sourceLocation.line):\(sourceLocation.column)"
44+
#else
45+
let location = "\(sourceLocation.debugDescription)"
46+
#endif
4247
print(
4348
"""
4449
===
45-
Formatting the following code produced diagnostic at location \(sourceLocation.debugDescription) (see end):
50+
Formatting the following code produced diagnostic at location \(location) (see end):
4651
---
4752
\(self.withLineNumberPrefixes)
4853
---

Tests/OpenAPIGeneratorReferenceTests/FileBasedReferenceTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ class FileBasedReferenceTests: XCTestCase {
4444
#endif
4545
}
4646

47-
func testPetstore() throws {
48-
try _test(referenceProject: .init(name: .petstore))
49-
}
47+
#if canImport(SwiftSyntax509)
48+
func testPetstore() throws {
49+
try _test(referenceProject: .init(name: .petstore))
50+
}
51+
#endif
5052

5153
// MARK: - Private
5254

Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Client.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public struct Client: APIProtocol {
4949
try await client.send(
5050
input: input,
5151
forOperation: Operations.listPets.id,
52-
serializer: { input in let path = try converter.renderedPath(template: "/pets", parameters: [])
52+
serializer: { input in
53+
let path = try converter.renderedPath(template: "/pets", parameters: [])
5354
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
5455
suppressMutabilityWarning(&request)
5556
try converter.setQueryItemAsURI(
@@ -144,7 +145,8 @@ public struct Client: APIProtocol {
144145
try await client.send(
145146
input: input,
146147
forOperation: Operations.createPet.id,
147-
serializer: { input in let path = try converter.renderedPath(template: "/pets", parameters: [])
148+
serializer: { input in
149+
let path = try converter.renderedPath(template: "/pets", parameters: [])
148150
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
149151
suppressMutabilityWarning(&request)
150152
try converter.setHeaderFieldAsJSON(
@@ -225,7 +227,8 @@ public struct Client: APIProtocol {
225227
try await client.send(
226228
input: input,
227229
forOperation: Operations.createPetWithForm.id,
228-
serializer: { input in let path = try converter.renderedPath(template: "/pets/create", parameters: [])
230+
serializer: { input in
231+
let path = try converter.renderedPath(template: "/pets/create", parameters: [])
229232
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
230233
suppressMutabilityWarning(&request)
231234
let body: OpenAPIRuntime.HTTPBody?
@@ -253,7 +256,8 @@ public struct Client: APIProtocol {
253256
try await client.send(
254257
input: input,
255258
forOperation: Operations.getStats.id,
256-
serializer: { input in let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
259+
serializer: { input in
260+
let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
257261
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
258262
suppressMutabilityWarning(&request)
259263
converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept)
@@ -302,7 +306,8 @@ public struct Client: APIProtocol {
302306
try await client.send(
303307
input: input,
304308
forOperation: Operations.postStats.id,
305-
serializer: { input in let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
309+
serializer: { input in
310+
let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
306311
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
307312
suppressMutabilityWarning(&request)
308313
let body: OpenAPIRuntime.HTTPBody?
@@ -342,7 +347,8 @@ public struct Client: APIProtocol {
342347
try await client.send(
343348
input: input,
344349
forOperation: Operations.probe.id,
345-
serializer: { input in let path = try converter.renderedPath(template: "/probe/", parameters: [])
350+
serializer: { input in
351+
let path = try converter.renderedPath(template: "/probe/", parameters: [])
346352
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
347353
suppressMutabilityWarning(&request)
348354
return (request, nil)

0 commit comments

Comments
 (0)