Skip to content

Commit

Permalink
clean up some temporary test code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Apr 23, 2024
1 parent 76d27d6 commit 9ed9570
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,39 +246,7 @@ final class ExternalDereferencingDocumentTests: XCTestCase {
try await docCopy3.externallyDereference(in: ExampleLoader.self, depth: .full)
docCopy3.components.sort()

// print("-----")
// print(docCopy2 == docCopy3)
// print(docCopy2.components == docCopy3.components)
// print("+++++")
// print(docCopy2.components.schemas == docCopy3.components.schemas)
// print(docCopy2.components.responses == docCopy3.components.responses)
// print(docCopy2.components.parameters == docCopy3.components.parameters)
// print(docCopy2.components.examples == docCopy3.components.examples)
// print(docCopy2.components.requestBodies == docCopy3.components.requestBodies)
// print(docCopy2.components.headers == docCopy3.components.headers)
// print(docCopy2.components.securitySchemes == docCopy3.components.securitySchemes)
// print(docCopy2.components.links == docCopy3.components.links)
// print(docCopy2.components.callbacks == docCopy3.components.callbacks)
// print(docCopy2.components.pathItems == docCopy3.components.pathItems)
// print("=====")
// print(docCopy2.components.responses)
// print("&&&&&")
// print(docCopy3.components.responses)
// print("$$$$$")

XCTAssertEqual(docCopy1, docCopy2)
XCTAssertEqual(docCopy2, docCopy3)
// XCTAssertEqual(String(describing: docCopy2), String(describing: docCopy3))

// - MARK: After
// print(
// String(data: try encoder.encode(docCopy1), encoding: .utf8)!
// )
// print(
// String(data: try encoder.encode(docCopy2), encoding: .utf8)!
// )
// print(
// String(data: try encoder.encode(docCopy3), encoding: .utf8)!
// )
}
}
50 changes: 0 additions & 50 deletions Tests/OpenAPIKitTests/Path Item/PathItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,53 +433,3 @@ extension PathItemTests {
)
}
}

// MARK: External Dereferencing Tests
extension PathItemTests {
struct MockLoad: ExternalLoader {
static func componentKey<T>(type: T.Type, at url: URL) throws -> OpenAPI.ComponentKey {
let urlString = url.pathComponents.dropFirst().joined(separator: "_").replacingOccurrences(of: ".", with: "_")

return try .forceInit(rawValue: urlString)
}

static func load<T>(_: URL) throws -> T where T : Decodable {
if let ret = OpenAPI.Request(description: "hello", content: [:]) as? T {
return ret
}
if let ret = OpenAPI.Parameter(name: "other-param", context: .header, schema: .string) as? T {
return ret
}
throw ValidationError(reason: "", at: [])
}
}

func test_tmp() async throws {
let op = OpenAPI.Operation(responses: [:])
let pathItem = OpenAPI.PathItem(
summary: "summary",
description: "description",
servers: [OpenAPI.Server(url: URL(string: "http://google.com")!)],
parameters: [
.parameter(name: "hello", context: .query, schema: .string),
.reference(.component(named: "already-internal")),
.reference(.external(URL(string: "https://some-param.com/param")!))
],
get: .init(requestBody: .reference(.external(URL(string: "https://website.com/request")!)), responses: [:]),
put: op,
post: op,
delete: op,
options: op,
head: op,
patch: op,
trace: op
)

print(pathItem.parameters.debugDescription)
print("------")
let (x, loaderComponents) = try await pathItem.externallyDereferenced(with: MockLoad.self)
print(x.parameters.debugDescription)
print("=======")
print(loaderComponents.parameters)
}
}

0 comments on commit 9ed9570

Please sign in to comment.