-
Notifications
You must be signed in to change notification settings - Fork 43
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
Added a Validation that checks all operationIds in Link objects are valid #404
base: main
Are you sure you want to change the base?
Added a Validation that checks all operationIds in Link objects are valid #404
Conversation
Thanks! Superficially this looks good. I’ll take a closer look soon. |
Looks like I'll have to take a look at the pet store spec failures. Don't see that being related to this PR unless I missed a modification to that test file on read through. |
If there’s anything I missed or need to change, please let me know. I’ll double check and make sure everything’s in order. I’ve already tested it locally, and the test cases are passing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding some missing tests while you were in there! I left one question but nothing else looks amiss.
let operationIds = context.document.paths.values | ||
.compactMap { context.document.components[$0] } | ||
.flatMap { $0.endpoints } | ||
.compactMap { $0.operation.operationId } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use the allOperationIds
helper here like you did for the OpenAPIKit
module's validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’re right, we can use allOperationIds
here as well. I overlooked that in the module validation—thanks for pointing it out!
I've fixed the tests that were broken for no reason connected to this PR and merged that in. |
The one remaining test failure is related to the security requirements validation test you added. As best I can tell (and I don't have memory one way or the other) the validation you are testing does not exist. Did you intend to add one? The validity of security requirements is asserted while decoding documents, but there is not a |
I took another look, and you’re right—there isn’t a separate validation step for security requirements; it’s handled implicitly during decoding. I had originally assumed there was a dedicated validation function for it, but that’s not the case. I’ll go ahead and adjust the test (or remove it if it no longer makes sense in this context) and update the implementation accordingly. ThankYou! |
Issue #236
This PR directly addresses the issue mentioned in the GitHub project (issue #236) for OpenAPIKit.
I have added a validation that ensures operationIds in Link objects refer to actual Operations that exist in the document.
Changes
I've created a new optional validation called linkOperationsExist that verifies Link objects with operationIds are pointing to valid Operations in the document.
Extracting the operationId from the Link object (ignoring Links that use operationRef instead)
This validation is optional and not included in the default validator.
The PR completes the TODO item in the project while maintaining consistency with the existing validation framework, ensuring that OpenAPI documents can be properly validated for correctness in their Link references.