Skip to content

Relax dependency on SwiftSyntax and SwiftFormat to 508..<510 #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ let package = Package(
// Generate Swift code
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "508.0.1"
"508.0.1"..<"510.0.0"
),

// Format Swift code
.package(
url: "https://github.com/apple/swift-format.git",
from: "508.0.1"
"508.0.1"..<"510.0.0"
),

// General algorithms
Expand Down
7 changes: 6 additions & 1 deletion Sources/_OpenAPIGeneratorCore/Extensions/SwiftFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ extension String {
assumingFileURL: nil,
to: &formattedString
) { diagnostic, sourceLocation in
#if canImport(SwiftSyntax509)
let location = "\(sourceLocation.line):\(sourceLocation.column)"
#else
let location = "\(sourceLocation.debugDescription)"
#endif
print(
"""
===
Formatting the following code produced diagnostic at location \(sourceLocation.debugDescription) (see end):
Formatting the following code produced diagnostic at location \(location) (see end):
---
\(self.withLineNumberPrefixes)
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ class FileBasedReferenceTests: XCTestCase {
}

func testPetstore() throws {
#if canImport(SwiftSyntax509)
try _test(referenceProject: .init(name: .petstore))
#else
XCTFail("Update SwiftFormat to at least 509 to run this test.")
#endif
}

// MARK: - Private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public struct Client: APIProtocol {
try await client.send(
input: input,
forOperation: Operations.listPets.id,
serializer: { input in let path = try converter.renderedPath(template: "/pets", parameters: [])
serializer: { input in
let path = try converter.renderedPath(template: "/pets", parameters: [])
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
suppressMutabilityWarning(&request)
try converter.setQueryItemAsURI(
Expand Down Expand Up @@ -144,7 +145,8 @@ public struct Client: APIProtocol {
try await client.send(
input: input,
forOperation: Operations.createPet.id,
serializer: { input in let path = try converter.renderedPath(template: "/pets", parameters: [])
serializer: { input in
let path = try converter.renderedPath(template: "/pets", parameters: [])
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
suppressMutabilityWarning(&request)
try converter.setHeaderFieldAsJSON(
Expand Down Expand Up @@ -225,7 +227,8 @@ public struct Client: APIProtocol {
try await client.send(
input: input,
forOperation: Operations.createPetWithForm.id,
serializer: { input in let path = try converter.renderedPath(template: "/pets/create", parameters: [])
serializer: { input in
let path = try converter.renderedPath(template: "/pets/create", parameters: [])
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
suppressMutabilityWarning(&request)
let body: OpenAPIRuntime.HTTPBody?
Expand Down Expand Up @@ -253,7 +256,8 @@ public struct Client: APIProtocol {
try await client.send(
input: input,
forOperation: Operations.getStats.id,
serializer: { input in let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
serializer: { input in
let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
suppressMutabilityWarning(&request)
converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept)
Expand Down Expand Up @@ -302,7 +306,8 @@ public struct Client: APIProtocol {
try await client.send(
input: input,
forOperation: Operations.postStats.id,
serializer: { input in let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
serializer: { input in
let path = try converter.renderedPath(template: "/pets/stats", parameters: [])
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
suppressMutabilityWarning(&request)
let body: OpenAPIRuntime.HTTPBody?
Expand Down Expand Up @@ -342,7 +347,8 @@ public struct Client: APIProtocol {
try await client.send(
input: input,
forOperation: Operations.probe.id,
serializer: { input in let path = try converter.renderedPath(template: "/probe/", parameters: [])
serializer: { input in
let path = try converter.renderedPath(template: "/probe/", parameters: [])
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .post)
suppressMutabilityWarning(&request)
return (request, nil)
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-compose.2204.510.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ services:
image: *image
environment:
- WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
# SwiftSyntax currently imports a module it does not explicitly depend
# on and so we must disable this for the time being.
# - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete

shell:
Expand Down
6 changes: 5 additions & 1 deletion docker/docker-compose.2204.58.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ services:
# pipeline.
#
# - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error

# SwiftSyntax currently imports a module it does not explicitly depend
# on and so we must disable this for the time being.
# - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error

- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete

shell:
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-compose.2204.59.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ services:
image: *image
environment:
- WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
# SwiftSyntax currently imports a module it does not explicitly depend
# on and so we must disable this for the time being.
# - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete

shell:
Expand Down
6 changes: 5 additions & 1 deletion docker/docker-compose.2204.main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ services:
# pipeline.
#
# - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error

# SwiftSyntax currently imports a module it does not explicitly depend
# on and so we must disable this for the time being.
# - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error

- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete

shell:
Expand Down