Skip to content

Commit c41395a

Browse files
Bumps OpenAPIKit to version 3.0.0-alpha.7 fixing an issue with trailing slashes. (#69)
### Motivation As discussed in #51, there was an issue with paths containing trailing slashes. The problem was identified in the [OpenAPIKit](https://github.com/mattpolzin/OpenAPIKit) dependency. It was fixed in the PR mattpolzin/OpenAPIKit#274. ### Modifications This PR updates the OpenAPIKit dependency version from `3.0.0-alpha.6` to `3.0.0-alpha.7` ([available here](https://github.com/mattpolzin/OpenAPIKit/releases/tag/3.0.0-alpha.7)), which includes the mentioned PR. ### Result If a path ends with a trailing slash, such as `foo/bar/`, the generated functions will now correctly call the path `foo/bar/` instead of (as previously) `foo/bar`. ### Test Plan Replaced an endpoint in the reference test to use a path with a trailing slash. ### Resolves - Resolves #51 --------- Co-authored-by: Miguel Ferreira <miguel.ferreira@unbabel.com>
1 parent 2c9fc55 commit c41395a

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let package = Package(
4747
// Read OpenAPI documents
4848
.package(
4949
url: "https://github.com/mattpolzin/OpenAPIKit.git",
50-
exact: "3.0.0-alpha.6"
50+
exact: "3.0.0-alpha.7"
5151
),
5252
.package(
5353
url: "https://github.com/jpsim/Yams.git",

Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ paths:
113113
$ref: '#/components/schemas/Pet'
114114
'400':
115115
$ref: '#/components/responses/ErrorBadRequest'
116-
/probe:
116+
/probe/:
117117
post:
118118
operationId: probe
119119
responses:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ public struct Client: APIProtocol {
211211
}
212212
)
213213
}
214-
/// - Remark: HTTP `POST /probe`.
215-
/// - Remark: Generated from `#/paths//probe/post(probe)`.
214+
/// - Remark: HTTP `POST /probe/`.
215+
/// - Remark: Generated from `#/paths//probe//post(probe)`.
216216
public func probe(_ input: Operations.probe.Input) async throws -> Operations.probe.Output {
217217
try await client.send(
218218
input: input,
219219
forOperation: Operations.probe.id,
220220
serializer: { input in
221-
let path = try converter.renderedRequestPath(template: "/probe", parameters: [])
221+
let path = try converter.renderedRequestPath(template: "/probe/", parameters: [])
222222
var request: OpenAPIRuntime.Request = .init(path: path, method: .post)
223223
suppressMutabilityWarning(&request)
224224
return request

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
265265
}
266266
)
267267
}
268-
/// - Remark: HTTP `POST /probe`.
269-
/// - Remark: Generated from `#/paths//probe/post(probe)`.
268+
/// - Remark: HTTP `POST /probe/`.
269+
/// - Remark: Generated from `#/paths//probe//post(probe)`.
270270
func probe(request: Request, metadata: ServerRequestMetadata) async throws -> Response {
271271
try await handle(
272272
request: request,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public protocol APIProtocol: Sendable {
1919
/// - Remark: HTTP `POST /pets`.
2020
/// - Remark: Generated from `#/paths//pets/post(createPet)`.
2121
func createPet(_ input: Operations.createPet.Input) async throws -> Operations.createPet.Output
22-
/// - Remark: HTTP `POST /probe`.
23-
/// - Remark: Generated from `#/paths//probe/post(probe)`.
22+
/// - Remark: HTTP `POST /probe/`.
23+
/// - Remark: Generated from `#/paths//probe//post(probe)`.
2424
func probe(_ input: Operations.probe.Input) async throws -> Operations.probe.Output
2525
/// Update just a specific property of an existing pet. Nothing is updated if no request body is provided.
2626
///
@@ -1004,8 +1004,8 @@ public enum Operations {
10041004
case undocumented(statusCode: Int, OpenAPIRuntime.UndocumentedPayload)
10051005
}
10061006
}
1007-
/// - Remark: HTTP `POST /probe`.
1008-
/// - Remark: Generated from `#/paths//probe/post(probe)`.
1007+
/// - Remark: HTTP `POST /probe/`.
1008+
/// - Remark: Generated from `#/paths//probe//post(probe)`.
10091009
public enum probe {
10101010
public static let id: String = "probe"
10111011
public struct Input: Sendable, Equatable, Hashable {
@@ -1079,7 +1079,7 @@ public enum Operations {
10791079
}
10801080
/// Ack
10811081
///
1082-
/// - Remark: Generated from `#/paths//probe/post(probe)/responses/204`.
1082+
/// - Remark: Generated from `#/paths//probe//post(probe)/responses/204`.
10831083
///
10841084
/// HTTP response code: `204 noContent`.
10851085
case noContent(Operations.probe.Output.NoContent)

Tests/PetstoreConsumerTests/Test_Client.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ final class Test_Client: XCTestCase {
344344
func testProbe_204() async throws {
345345
transport = .init { request, baseURL, operationID in
346346
XCTAssertEqual(operationID, "probe")
347-
XCTAssertEqual(request.path, "/probe")
347+
XCTAssertEqual(request.path, "/probe/")
348348
XCTAssertNil(request.query)
349349
XCTAssertEqual(baseURL.absoluteString, "/api")
350350
XCTAssertEqual(request.method, .post)

0 commit comments

Comments
 (0)