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.Interface
No new interfaces are introduced.
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.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /coral, current file: none) bash-$
Assistant
Let me start by exploring the repository structure to understand the codebase and find the relevant code related to OpenAPI path parameters import in v4.
Assistant
This appears to be a Rust project. Let me look at the PR reference mentioned in the issue to understand the context better, and search for relevant code related to OpenAPI import and path parameters.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "OpenAPI" --include="*.rs" | head -50 </tool_call>
Assistant
The previous grep command wasn't executed properly. Let me try again with the correct format.
Assistant
Let me look at the OpenAPI import file and the PR discussion mentioned in the issue. The key file seems to be
crates/coral-spec/src/v4/surfaces/openapi/import.rs.<tool_call> <function=open> <parameter=file> /coral/crates/coral-spec/src/v4/surfaces/openapi/import.rs </tool_call>
Assistant
I need to use the correct tool format. Let me open the file properly.
Assistant
I see the import.rs file but it seems incomplete. Let me search for where path parameters are being handled and the
requiredfield is being checked.<tool_call> <function=bash_terminal> <parameter=command> grep -r "required" --include="*.rs" /coral/crates/coral-spec/src/v4/surfaces/openapi/ </tool_call>
Assistant
Let me run the grep command properly.
Assistant
Now let me look at the operations.rs file where the path parameters are being processed and the
requiredfield is being used.Assistant
Now I can see the issue. In the
import_parametersfunction, when importing parameters, the code checks forrequiredfield:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),The problem is that when
requiredis omitted, it defaults tofalse(viaunwrap_or(false)). However, according to OpenAPI specification, path parameters are always required even if therequiredfield is omitted. The fix should check if the parameter location is "path" and if so, always setrequiredtotrueregardless of whether therequiredfield is present.Let me look at the tests to understand the expected behavior better and see if there are any existing tests for path parameters.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "path" --include="*.rs" /coral/crates/coral-spec/src/v4/projection_tests.rs | head -30 </tool_call>
Assistant
I need to use bash_terminal correctly.
Assistant
Let me look at the projection_tests.rs file to see what kind of tests exist for the OpenAPI importer, especially for path parameters without the
requiredfield.Assistant
I notice that in all the tests, the path parameters have
required: trueexplicitly set. But the issue is about whenrequiredis omitted - it should still be treated as required for path parameters.Let me look for the GitHub OpenAPI fixture to understand the actual data format better.
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/test_support.rs 2>/dev/null || find /coral -name "test_support*" -type f </tool_call>
Assistant
Let me run the command properly using bash_terminal.
Assistant
The user is asking me to use
bash_terminalcorrectly. Looking at my previous responses, I see I was usingbash_terminalcorrectly. The issue was that the search was returning output but not being presented as a valid response to me.Let me now focus on the task at hand. I need to:
- Understand the issue - path parameters in OpenAPI should be required even when
requiredis omitted - Find where the code handles this
- Make the fix
- Verify the fix
Let me look at the operations.rs file to understand where the fix needs to be made.
- Understand the issue - path parameters in OpenAPI should be required even when
Assistant
Now I understand the issue. Looking at the
import_parametersfunction inoperations.rs, the code currently defaultsrequiredtofalsewhen the field is omitted:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),According to OpenAPI specification, path parameters should be required even when the
requiredfield is omitted. The fix should check if the parameter location is "path" and, ifrequiredis omitted, default totruefor path parameters butfalsefor others.Let me make the fix:
Assistant
I need to find the specific line where path parameters are being processed and modify the logic to treat them as required by default.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '150,170p' /coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs </tool_call>
Assistant
I need to use bash_terminal to run the command.
Assistant
Now I can see the exact location. The issue is at line 158-161 where
requiredis being set. For path parameters, ifrequiredis omitted, it should default totrueinstead offalse.The fix is to change the logic to:
- If location is "path" and
requiredis not explicitly set, default totrue - For other locations, keep the existing behavior (default to
falseifrequiredis not set)
Let me also check if there's a constant or enum for
OpenApiParameterLocation:<tool_call> <function=bash_terminal> <parameter=command> grep -r "OpenApiParameterLocation" /coral/crates/coral-spec/src/v4/ir/ | head -20 </tool_call>
- If location is "path" and
Assistant
I need to search for the OpenApiParameterLocation definition using bash_terminal.
Assistant
Let me see the definition of OpenApiParameterLocation:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 10 "pub enum OpenApiParameterLocation" /coral/crates/coral-spec/src/v4/ir/model.rs </tool_call>
Assistant
Let me run the grep command properly.
Assistant
Now I understand the issue and can make the fix. The problem is in the
import_parametersfunction inoperations.rs. Whenrequiredis omitted for a path parameter, it should default totrueinstead offalse, as per OpenAPI specification.Let me apply the fix:
Assistant
Now I understand the issue. The code currently defaults
requiredtofalsefor all parameters when therequiredfield is omitted. However, according to OpenAPI specification, path parameters are required by default even when therequiredfield is omitted.Let me make the fix to handle path parameters as required by default:
Assistant
I need to verify the fix was applied correctly. Let me check the file to see if the change was made properly.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '156,164p' /coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs </tool_call>
Assistant
I need to use the bash_terminal tool correctly. Let me verify the change was applied.
Assistant
I see the sed command affected more than intended. The
import_request_bodyfunction also got the change, but that's not correct - only the parameterrequiredfield should default totruefor path parameters. Let me revert the unintended change:Assistant
Let me check the current state and fix it properly:
Assistant
I see the sed command made unintended changes. Let me reset the file and apply the fix properly:
Assistant
Let me verify the file is back to its original state and then apply the fix correctly:
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs | grep -n "unwrap_or" </tool_call>
Assistant
The sed command is not being executed properly. Let me try a different approach.
Assistant
Good, the file is back to its original state. Now I need to apply the fix correctly. Looking at the output, line 161 is the
requiredfield for parameters which is the one I need to change. The fix should be:- Line 161: Change
.unwrap_or(false)to.unwrap_or(location == OpenApiParameterLocation::Path)
Let me use the
editcommand to make this change properly:<tool_call> <function=bash_terminal> <parameter=command> cat -n /coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs | sed -n '155,170p' </tool_call>
- Line 161: Change
Assistant
I need to run the command properly to see the exact lines.
Assistant
Now I can see the exact lines. I need to change line 161 to default to
truefor path parameters. Let me use theeditcommand:Assistant
The edit was successful. Let me verify the change was applied correctly:
Assistant
The fix was applied correctly. Now let me verify the code compiles:
Assistant
The compilation is in progress. Let me wait for it to finish:
Assistant
Now let me run the existing tests to make sure my fix doesn't break anything:
<tool_call> <function=bash_terminal> <parameter=command> cd /coral && cargo test --package coral-spec 2>&1 | tail -50 </tool_call>
Assistant
I need to run the command properly using bash_terminal. Let me run the tests.
Assistant
The tests pass. Now let me also run the specific OpenAPI tests to ensure the fix works correctly. Let me also look at the issue description to see if there's a test coverage requirement. The issue mentions:
Import path parameters as required regardless of an omitted
requiredfield, preserve explicit behavior for non-path parameters, and add focused importer/projection coverage.So I need to add tests to cover:
- Path parameters without explicit
requiredshould be treated as required - Non-path parameters with omitted
requiredshould still be treated as optional
Let me first look for existing tests related to the importer and projection tests.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "path.required" /coral/crates/coral-spec/src/v4/ --include=".rs" | head -20 </tool_call>
- Path parameters without explicit
Assistant
I need to search for path parameter tests using bash_terminal correctly.
Assistant
I see that all existing tests explicitly set
required: truefor path parameters. I need to add a test that verifies path parameters without therequiredfield are still treated as required. Let me look for openapi_tests.rs which seems to have tests specifically for the OpenAPI importer:<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/openapi_tests.rs </tool_call>
Assistant
I need to run the cat command to see the openapi_tests.rs file.
Assistant
Now I have a good understanding of the test file structure. I need to add a test that verifies:
- Path parameters without explicit
requiredfield are treated as required - Non-path parameters without explicit
requiredfield are treated as optional (false)
Let me first check how to properly add a test that checks the
requiredfield onIrOperationInput. Let me search for how the existing tests check therequiredfield:<tool_call> <function=bash_terminal> <parameter=command> grep -n "required" /coral/crates/coral-spec/src/v4/openapi_tests.rs </tool_call>
- Path parameters without explicit
Assistant
I need to search for "required" in the openapi_tests.rs file using bash_terminal correctly.
Assistant
The issue mentions that I need to add focused importer/projection coverage tests for path parameters. Let me look at how the tests check the
requiredfield onIrOperationInput. I'll search for howrequiredis accessed in tests:<tool_call> <function=bash_terminal> <parameter=command> grep -r ".required" /coral/crates/coral-spec/src/v4/ --include="*.rs" | head -20 </tool_call>
Assistant
I need to search for
.requiredin the codebase. Let me use bash_terminal to search properly.Assistant
Now I can see how
requiredis used in the codebase. The key place isderive.rswhere it's used to determine if inputs are required for SQL. I need to add tests that verify:- Path parameters without
requiredfield are treated as required - Non-path parameters without
requiredfield are treated as optional
Let me look at the IrOperationInput structure to understand what fields are available:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 10 "pub struct IrOperationInput" /coral/crates/coral-spec/src/v4/ir/model.rs </tool_call>
- Path parameters without
Assistant
I need to use bash_terminal to run this grep command to see the IrOperationInput structure.
Assistant
Now I understand the structure. The
IrOperationInputhas arequiredfield that I need to verify. Let me add a test that verifies:- Path parameters without explicit
requiredfield are treated as required (true) - Non-path parameters without explicit
requiredfield are treated as optional (false)
Let me also check where the tests are located and how they're organized:
<tool_call> <function=bash_terminal> <parameter=command> ls -la /coral/crates/coral-spec/src/v4/ </tool_call>
- Path parameters without explicit
Assistant
I need to use bash_terminal to run the ls command to list the v4 directory contents.
Assistant
Now I can see the file structure. I need to add a test to verify the path parameters are treated as required when
requiredis omitted. Let me look at the end of openapi_tests.rs to see where I can add the new test:<tool_call> <function=bash_terminal> <parameter=command> tail -50 /coral/crates/coral-spec/src/v4/openapi_tests.rs </tool_call>
Assistant
The user is asking me to run a command. Looking at the current file which is
/coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs, and the task at hand, I need to check the end of the openapi_tests.rs file to see where I should add the new test. Let me run the tail command using bash_terminal.Assistant
Now I need to add a test to verify that path parameters are treated as required when the
requiredfield is omitted. Let me add this test to the openapi_tests.rs file:Assistant
Now let me verify the tests were added correctly and run them to make sure my fix works:
Assistant
The first test passed. Let me run all three new tests to verify the fix is working correctly:
Assistant
I need to use the correct syntax for filtering multiple tests. Let me try with a pattern match.
Assistant
All three new tests passed. Now let me run all the tests to ensure the fix doesn't break any existing functionality:
Assistant
All 222 tests pass. Now let me also run the projection tests to make sure the fix works correctly in the full projection generation workflow:
Assistant
All tests pass. Let me now verify the exact change I made and ensure it's correct:
<tool_call> <function=bash_terminal> <parameter=command> cd /coral && git diff crates/coral-spec/src/v4/surfaces/openapi/operations.rs </tool_call>
Assistant
The user is asking me to run a command. I need to use bash_terminal to show the git diff for the operations.rs file.
Assistant
Let me also check the diff for the test file:
Assistant
Now let me also verify the tests work with a broader test run to ensure nothing is broken. Let me run the full test suite for coral-spec:
<tool_call> <function=bash_terminal> <parameter=command> cd /coral && cargo test --package coral-spec 2>&1 | head -50 </tool_call>
Assistant
The user wants me to run a command using bash_terminal. Let me run the full test suite for coral-spec to verify everything is working.
Assistant
The tests are running. Let me wait for them to complete to ensure everything passes.
Assistant
All 222 tests pass and the doc tests pass. Now let me summarize what I've done and make sure I've addressed all the requirements from the issue.
Summary
The issue was:
- OpenAPI path parameters are imported as optional when
requiredis omitted, even though path parameters are required by OpenAPI specification. - This can misclassify required path inputs as optional SQL filters.
Fix Applied
-
Modified
crates/coral-spec/src/v4/surfaces/openapi/operations.rs:- Changed line 161 from
.unwrap_or(false)to.unwrap_or(location == OpenApiParameterLocation::Path) - This ensures that path parameters default to
required: truewhen therequiredfield is omitted, while non-path parameters (query, header, cookie) default torequired: false.
- Changed line 161 from
-
Added tests in
crates/coral-spec/src/v4/openapi_tests.rs:importer_treats_path_parameters_as_required_by_default: Tests that path parameters without explicitrequiredfield are treated as required, while query and header parameters without explicitrequiredare treated as optional.importer_preserves_explicit_required_false_for_path_parameters: Tests that explicitrequired: falseis preserved for path parameters (even though this is invalid OpenAPI).importer_preserves_explicit_required_true_for_query_parameters: Tests that explicitrequired: trueis preserved for query parameters.
All 222 tests pass. The fix addresses the acceptance criteria:
- ✅ Import path parameters as required regardless of an omitted
requiredfield - ✅ Preserve explicit behavior for non-path parameters
- ✅ Added focused importer/projection coverage with tests
Let me verify the changes one more time before submitting. </tool_call>
- OpenAPI path parameters are imported as optional when
Assistant
The user wants me to verify the changes before submitting. Let me run a final check to make sure all changes are in place and tests pass.
Assistant
Let me verify the changes are correct by looking at the diffs again:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →