Skip to content

Conversation

@Tuntii
Copy link
Owner

@Tuntii Tuntii commented Feb 6, 2026

Extended validate_integrity to visit parameters, responses, request bodies, headers, and callbacks in the components section 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

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 6, 2026 03:42
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Contributor

Copilot AI left a 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_integrity to validate schema references in components.parameters, components.responses, components.request_bodies, components.headers, and components.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_invalid to 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

Comment on lines +241 to +269
#[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()));
}
Copy link

Copilot AI Feb 6, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant