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
I'll start by exploring the repository structure to understand the codebase and locate relevant files. Let's first check the root directory.
- Assistant
Let me understand the repo structure better and find files related to OpenAPI path parameters.
- Assistant
Let me look at the OpenAPI import file more closely, since that's likely where the issue is.
- Assistant
Let me start by examining the OpenAPI import file, which is the most likely place where path parameters are being imported.
- Assistant
Now let me look at the operations file where parameters are likely processed:
- Assistant
I can see the issue! In the
import_parametersfunction, therequiredfield defaults tofalsewhen omitted, but according to OpenAPI specification, path parameters are always required. Let me examine the IR types to understand the data structures better: - Assistant
Now let me check the existing tests to understand the expected behavior:
- Assistant
Let me check the projection tests to understand how required parameters are used:
- Assistant
Let me check the projection generation code to see how required parameters are handled there:
- Assistant
Let me examine the derive.rs file to understand how required parameters are used in projections:
- Assistant
Now I understand the issue. Let me create a test to reproduce the problem and then fix it:
- Assistant
Let me first verify the current behavior by running the existing tests to understand the baseline:
- Assistant
Let me wait for the test to complete.
- Assistant
Now let me run the projection tests as well:
- Assistant
Now let me create a proper test to reproduce the issue. First, let me examine the existing test structure more closely:
- Assistant
Let me check the test structure properly.
- Assistant
Let me look at the end of the openapi_tests.rs file to understand the structure better:
- Assistant
Now I understand the structure. Let me create a test to reproduce the issue:
- Assistant
Now let me add this test to the openapi_tests.rs file and see if it fails:
- Assistant
Let me check what imports are needed by looking at the top of the test file:
- Assistant
Let me look at what's imported via
super::*: - Assistant
Let me run the test to see if it fails as expected:
- Assistant
Good! The test fails as expected, confirming the bug. Now let me fix it. The fix is in
operations.rsin theimport_parametersmethod. We need to make path parameters required by default (when therequiredfield is omitted). - Assistant
Let me look at the exact code that handles the
requiredfield in theimport_parametersmethod: - Assistant
Let me look at the relevant section in the operations.rs file:
- Assistant
Now I understand the issue. Looking at lines 158-161, the
requiredfield defaults tofalsewhen omitted. According to OpenAPI specification, path parameters should always be required. Let me implement the fix: - Assistant
Now let me run the test to see if it passes:
- Assistant
Great! Now let me run all the existing tests to make sure I didn't break anything:
- Assistant
Now let me run the projection tests:
- Assistant
Now let me also add a projection test to ensure the behavior is correct in the projection side as well. Let me examine the projection tests more closely:
- Assistant
Let me check how the projection model handles required inputs:
- Assistant
Let me check the full projection model:
- Assistant
Now let me add a projection test that verifies path parameters without required field are treated as required in projections:
- Assistant
Let me write the test to a file first and then append it:
- Assistant
Now let me run the projection tests to see if my new test passes:
- Assistant
Perfect! Now let me run all the projection tests to make sure everything still passes:
- Assistant
Now let me add a test for query parameters without required field to make sure they are still treated as optional:
- Assistant
Now let me run all the tests again to make sure everything passes:
- Assistant
Excellent! Let me run a broader test to make sure I haven't broken anything else:
- Assistant
Perfect! All tests pass. Let me verify my changes by looking at the diff:
- Assistant
Perfect! Let me verify the changes are correct by reviewing the key files:
- Assistant
Let me run a final comprehensive test to make sure everything is working:
- Assistant
Perfect! All tests pass. Let me now verify the complete solution by checking the changes I've made:
- Assistant
Let me run one final comprehensive test to ensure everything is working correctly:
- Assistant
Perfect! All 222 tests pass. Now let me provide my final summary of the changes I made:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.