Skip to content

Commit b4a1a4b

Browse files
committed
Use UUID type for response identifier as well
1 parent 67d72ec commit b4a1a4b

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ paths:
7979
required: true
8080
schema:
8181
type: string
82+
format: uuid
8283
My-Tracing-Header:
8384
$ref: '#/components/headers/TracingHeader'
8485
content:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public struct Client: APIProtocol {
109109
My_hyphen_Response_hyphen_UUID: try converter.getRequiredHeaderFieldAsURI(
110110
in: response.headerFields,
111111
name: "My-Response-UUID",
112-
as: Swift.String.self
112+
as: Foundation.UUID.self
113113
),
114114
My_hyphen_Tracing_hyphen_Header: try converter.getOptionalHeaderFieldAsURI(
115115
in: response.headerFields,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ public enum Operations {
18581858
/// Response identifier
18591859
///
18601860
/// - Remark: Generated from `#/paths/pets/GET/responses/200/headers/My-Response-UUID`.
1861-
public var My_hyphen_Response_hyphen_UUID: Swift.String
1861+
public var My_hyphen_Response_hyphen_UUID: Foundation.UUID
18621862
/// A description here.
18631863
///
18641864
/// - Remark: Generated from `#/paths/pets/GET/responses/200/headers/My-Tracing-Header`.
@@ -1869,7 +1869,7 @@ public enum Operations {
18691869
/// - My_hyphen_Response_hyphen_UUID: Response identifier
18701870
/// - My_hyphen_Tracing_hyphen_Header: A description here.
18711871
public init(
1872-
My_hyphen_Response_hyphen_UUID: Swift.String,
1872+
My_hyphen_Response_hyphen_UUID: Foundation.UUID,
18731873
My_hyphen_Tracing_hyphen_Header: Components.Headers.TracingHeader? = nil
18741874
) {
18751875
self.My_hyphen_Response_hyphen_UUID = My_hyphen_Response_hyphen_UUID

Tests/PetstoreConsumerTests/Common.swift

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
import XCTest
1515
import HTTPTypes
1616

17-
extension Operations.listPets.Output {
18-
static var success: Self { .ok(.init(headers: .init(My_hyphen_Response_hyphen_UUID: "abcd"), body: .json([]))) }
19-
}
20-
2117
extension HTTPRequest {
2218
/// Initializes an HTTP request with the specified path, HTTP method, and header fields.
2319
///

Tests/PetstoreConsumerTests/Test_Client.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ final class Test_Client: XCTestCase {
3737

3838
func testListPets_200() async throws {
3939
let requestUUID = UUID()
40+
let responseUUID = UUID()
4041
transport = .init { (request: HTTPRequest, body: HTTPBody?, baseURL: URL, operationID: String) in
4142
XCTAssertEqual(operationID, "listPets")
4243
XCTAssertEqual(
@@ -50,7 +51,7 @@ final class Test_Client: XCTestCase {
5051
return try HTTPResponse(
5152
status: .ok,
5253
headerFields: [
53-
.contentType: "application/json", .init("my-response-uuid")!: "abcd",
54+
.contentType: "application/json", .init("my-response-uuid")!: responseUUID.uuidString,
5455
.init("my-tracing-header")!: "1234",
5556
]
5657
)
@@ -75,7 +76,7 @@ final class Test_Client: XCTestCase {
7576
XCTFail("Unexpected response: \(response)")
7677
return
7778
}
78-
XCTAssertEqual(value.headers.My_hyphen_Response_hyphen_UUID, "abcd")
79+
XCTAssertEqual(value.headers.My_hyphen_Response_hyphen_UUID, responseUUID)
7980
XCTAssertEqual(value.headers.My_hyphen_Tracing_hyphen_Header, "1234")
8081
switch value.body {
8182
case .json(let pets): XCTAssertEqual(pets, [.init(id: 1, name: "Fluffz")])

Tests/PetstoreConsumerTests/Test_Server.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ final class Test_Server: XCTestCase {
2929

3030
func testListPets_200() async throws {
3131
let requestUUID = UUID()
32+
let responseUUID = UUID()
3233
client = .init(listPetsBlock: { input in
3334
XCTAssertEqual(input.query.limit, 24)
3435
XCTAssertEqual(input.query.habitat, .water)
@@ -37,7 +38,7 @@ final class Test_Server: XCTestCase {
3738
XCTAssertEqual(input.headers.My_hyphen_Request_hyphen_UUID, requestUUID)
3839
return .ok(
3940
.init(
40-
headers: .init(My_hyphen_Response_hyphen_UUID: "abcd", My_hyphen_Tracing_hyphen_Header: "1234"),
41+
headers: .init(My_hyphen_Response_hyphen_UUID: responseUUID, My_hyphen_Tracing_hyphen_Header: "1234"),
4142
body: .json([.init(id: 1, name: "Fluffz")])
4243
)
4344
)
@@ -55,7 +56,7 @@ final class Test_Server: XCTestCase {
5556
XCTAssertEqual(
5657
response.headerFields,
5758
[
58-
.init("My-Response-UUID")!: "abcd", .init("My-Tracing-Header")!: "1234",
59+
.init("My-Response-UUID")!: responseUUID.uuidString, .init("My-Tracing-Header")!: "1234",
5960
.contentType: "application/json; charset=utf-8", .contentLength: "47",
6061
]
6162
)

0 commit comments

Comments
 (0)