Skip to content

Commit 021f451

Browse files
Use allOperationIds helper in OpenAPIKit30 module and remove security requirements validation test
1 parent aae13e0 commit 021f451

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

Sources/OpenAPIKit30/Validator/Validation+Builtins.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,8 @@ extension Validation {
413413
return true
414414
}
415415

416-
// Collect all operation IDs from the document
417-
let operationIds = context.document.paths.values
418-
.compactMap { context.document.components[$0] }
419-
.flatMap { $0.endpoints }
420-
.compactMap { $0.operation.operationId }
416+
// Use the allOperationIds helper to get all operation IDs from the document
417+
let operationIds = context.document.allOperationIds
421418

422419
return operationIds.contains(operationId)
423420
}

Tests/OpenAPIKit30Tests/Validator/BuiltinValidationTests.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -750,29 +750,6 @@ final class BuiltinValidationTests: XCTestCase {
750750
try document.validate()
751751
}
752752

753-
func test_securityRequirementComponentsExist_fails() throws {
754-
let document = OpenAPI.Document(
755-
info: .init(title: "test", version: "1.0"),
756-
servers: [],
757-
paths: [:],
758-
components: .noComponents,
759-
security: [
760-
[.component(named: "oauth"): ["scope2"]]
761-
]
762-
)
763-
764-
XCTAssertThrowsError(try document.validate()) { error in
765-
let errorCollection = error as? ValidationErrorCollection
766-
XCTAssertEqual(errorCollection?.values.first?.reason, "Failed to satisfy: Security Requirement security scheme can be found in components/securitySchemes")
767-
XCTAssertEqual(errorCollection?.values.first?.codingPath.map { $0.stringValue }, ["security"])
768-
XCTAssertEqual(errorCollection?.values.count, 1)
769-
770-
let openAPIError = OpenAPI.Error(from: error)
771-
XCTAssertEqual(openAPIError.localizedDescription, "Failed to satisfy: Security Requirement security scheme can be found in components/securitySchemes at path: .security")
772-
XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["security"])
773-
}
774-
}
775-
776753
func test_linkOperationsExist_validates() throws {
777754
// Create a link with an operationId that exists in the document
778755
let link = OpenAPI.Link(operationId: "testOperation")

0 commit comments

Comments
 (0)