ISSUE DESCRIPTION Treat OpenAPI path parameters as required in v4 import This tracks…
- User
ISSUE DESCRIPTION
Treat OpenAPI path parameters as required in v4 import This tracks unresolved feedback identified by cubic on PR #1149: https://github.com/withcoral/coral/pull/1149#discussion_r3347190640
Context: This appears to be pre-existing DSL v4 behavior surfaced by the refactor review, not a regression from the module split.
Problem: OpenAPI path parameters are imported as optional when
requiredis omitted, even though path parameters are required by OpenAPI. This can misclassify required path inputs as optional SQL filters.Acceptance criteria: Import path parameters as required regardless of an omitted
requiredfield, preserve explicit behavior for non-path parameters, and add focused importer/projection coverage.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Assistant
Let me start by understanding the repository structure and the issue at hand.
The issue is about OpenAPI path parameters being imported as optional when
requiredis omitted in v4 import. Path parameters in OpenAPI are always required, but the current code treats them as optional if therequiredfield is not explicitly set. I need to:- Find the relevant code that handles OpenAPI parameter import
- Fix it so path parameters are always treated as required
- Add appropriate test coverage
Let me explore the repository structure first.
Assistant
Let me explore the structure further. The issue mentions OpenAPI path parameters and v4 import. Let me look at the PR reference and find relevant code.
Assistant
The main file seems to be
./crates/coral-spec/src/v4/surfaces/openapi/import.rs. Let me look at that file and also the operations.rs and the test filesAssistant
Now let me look at operations.rs to see how parameters are imported, specifically for path parameters:
Assistant
Now I can see the issue. In
operations.rs, line aroundimport_parameters, therequiredfield defaults tofalse:rustrequired: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),But OpenAPI specifies that path parameters are always required, even if the
requiredfield is omitted. Let me look at the test files to understand the testAssistant
Let me also look at the projection tests and the IR types:
Assistant
Let me look at the test support file and also understand the IR types better:
Assistant
Let me now understand how
requiredis used in the IR and projections:Assistant
Let me use the correct path.
Assistant
Let me look at the projection derive code to understand how
requiredaffects SQL exposure:Assistant
Now I understand the issue fully. Let me verify by checking the IR model types:
Assistant
Let me look at the rest.rs for RestParameterBinding:
Assistant
Now let me first run the existing tests to make sure they pass before making changes
Assistant
Good, all tests pass. Let me also run projection tests:
Assistant
All tests pass. Now let me implement the fix. The change is in
operations.rs- I need to defaultrequiredtotruefor path parameters:Assistant
Let me open the file first:
Assistant
Let me just use sed to make the replacement:
Assistant
Let me verify the change:
Assistant
Let me check the current state of the file around the changes:
Assistant
Oh no, the sed replaced ALL
.unwrap_or(false)occurrences. Let me see the git diff to understand all changes:Assistant
I need to revert the incorrect changes. The first (deprecated) and third (request body) changes are wrong. Let me restore the file and do it correctly
Assistant
Now let me make a more targeted edit using the replace command with the open file approach. Let me first open the file
Assistant
Let me scroll down to see the exact lines of the
import_parametersfunction whererequiredis set:Assistant
Now I can see the exact lines. Let me use the
replacecommand to make the targeted change:Assistant
Let me try using the edit command with line range:
Assistant
The edit duplicated lines. Let me restore the file:
Assistant
Let me use a more precise sed command, targeting only the specific line:
Assistant
Let me verify the change is correct:
Assistant
The change is exactly what we need. Let me verify it compiles and all tests pass:
Assistant
All 219 tests pass. Now let me write a quick test to verify the fix actually works for the reported scenario:
Assistant
Actually, let me just add a focused test to the existing test file. Let me look at the end of openapi_tests.rs:
Assistant
Let me look at the imports and beginning of the test file:
Assistant
Now let me add a focused test. Let me first see the end of the file more precisely:
Assistant
Let me add the importer test at the end of the file:
Assistant
Let me check if the types are in scope. Let me look at what
super::*brings in:Assistant
Let me check the public exports from the ir module:
Assistant
Good, the types are exported. Let me run the new test:
Assistant
The test fails because the operation IDs might be normalized differently. Let me check:
Assistant
Let me check how
normalize_identifierworks:Assistant
Let me debug by adding a temporary print statement:
Assistant
Let me check what the operation IDs actually are. Let me temporarily modify the test to print debug info:
Assistant
Let me see the rest of the test and figure out line 754:
Assistant
The issue is that the parameter name
x-headerhas a hyphen, and I looked it up asx_header. Let me fix the test:Assistant
Let me run the test again:
Assistant
The test passes. Now let me run all tests to ensure nothing is broken:
Assistant
Now let me add a projection test. Let me add it to projection_tests.rs:
Assistant
Let me run the new projection test:
Assistant
ProjectionKinddoesn't implementPartialEq. Let me simplify the test to focus on the exposures:Assistant
Let me check the model to see if there's a way to match on ProjectionKind:
Assistant
Let me add the projection test using
matches!macro:Assistant
Let me run the new projection test:
Assistant
Both tests pass. Let me run all tests one final time:
Assistant
All 221 tests pass. Let me also run the broader test suite to make sure nothing else is broken:
Assistant
Those 2 failures are pre-existing (in gRPC source lifecycle tests, unrelated to OpenAPI import). Let me verify my changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.