-
-
Notifications
You must be signed in to change notification settings - Fork 1
Validate references in all OpenAPI spec components #101
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
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.
Pull request overview
This PR extends the OpenAPI specification validation to check for missing schema references in all component types, not just in paths and webhooks. It refactors the visitor pattern to eliminate code duplication and adds comprehensive validation for components including parameters, responses, request bodies, headers, and callbacks.
Changes:
- Extended
validate_integrityto validate schema references incomponents.parameters,components.responses,components.request_bodies,components.headers, andcomponents.callbacks - Refactored visitor logic by extracting helper functions (
visit_parameter,visit_response,visit_request_body,visit_header,visit_media_type) to eliminate code duplication - Added regression test
test_ref_integrity_components_invalidto verify detection of invalid references in component parameters
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rustapi-openapi/src/spec.rs | Extended validate_integrity to cover all component types; refactored visitor pattern by extracting reusable helper functions for cleaner code |
| crates/rustapi-openapi/src/tests.rs | Added regression test for components validation using parameters as test case |
| #[test] | ||
| fn test_ref_integrity_components_invalid() { | ||
| let mut spec = OpenApiSpec::new("Test", "1.0"); | ||
| let mut components = crate::spec::Components::default(); | ||
|
|
||
| components.parameters.insert( | ||
| "badParam".to_string(), | ||
| crate::spec::Parameter { | ||
| name: "badParam".to_string(), | ||
| location: "query".to_string(), | ||
| required: false, | ||
| description: None, | ||
| deprecated: None, | ||
| schema: Some(SchemaRef::Ref { | ||
| reference: "#/components/schemas/NonExistent".to_string(), | ||
| }), | ||
| }, | ||
| ); | ||
|
|
||
| spec.components = Some(components); | ||
|
|
||
| let result = spec.validate_integrity(); | ||
| assert!( | ||
| result.is_err(), | ||
| "Should detect missing ref in components.parameters" | ||
| ); | ||
| let missing = result.unwrap_err(); | ||
| assert!(missing.contains(&"#/components/schemas/NonExistent".to_string())); | ||
| } |
Copilot
AI
Feb 6, 2026
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.
The new test only validates components.parameters, but the PR also adds validation for components.responses, components.request_bodies, components.headers, and components.callbacks. Consider adding test cases for these other component types to ensure comprehensive test coverage of the new validation logic.
Extended
validate_integrityto visit parameters, responses, request bodies, headers, and callbacks in thecomponentssection of the OpenAPI spec.Added regression test
test_ref_integrity_components_invalid.Refactored visitor logic to avoid code duplication.
PR created automatically by Jules for task 2490534079871699615 started by @Tuntii