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.
Assistant
Let me start by understanding the issue. The problem is about OpenAPI path parameters being imported as optional when they should always be required. Let me explore the repository structure first to understand the codebase.
Assistant
Let me explore the repository structure more broadly.
Assistant
This is a Rust project. Let me explore the crates directory to understand the structure better, and look for OpenAPI-related code.
Assistant
Let me look at coral-spec since that's likely where OpenAPI import logic lives.
Assistant
Let me look at the OpenAPI import file since that's where the issue likely is:
Assistant
Let me look at the operations file, which likely handles path parameters:
Assistant
Now I found the issue. In the
import_parametersfunction inoperations.rs, therequiredfield is determined only by what's specified in the OpenAPI parameter object, defaulting tofalse:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),According to the OpenAPI 3.0 specification, path parameters are always required even when
requiredis omitted. Let me check the related IR types and test files to understand the full context.Assistant
Let me check the IR model to understand the
IrOperationInputtype:Assistant
Let me look at the existing OpenAPI tests to understand the test patterns:
Assistant
Let me see the rest of the openapi_tests.rs file and also check the PR mentioned in the issue:
Assistant
Let me see the middle part of the openapi_tests.rs file to get the full picture:
<tool_call> <function=bash_terminal> <parameter=command> head -n 400 /coral/crates/coral-spec/src/v4/openapi_tests.rs </tool_call>
Assistant
Let me look at the openapi tests file to understand the pattern and check for existing path parameter tests.
Assistant
Now let me look at the projection tests to understand how tests are structured:
Assistant
Now I understand the issue. In the
import_parametersfunction inoperations.rs, path parameters are being imported withrequired: falsewhen therequiredfield is omitted from the OpenAPI spec. According to OpenAPI 3.0 specification, path parameters are always required.Let me first verify the issue by running the existing tests:
Assistant
The existing tests pass. Now let me create a test script to reproduce the issue - that path parameters without explicit
required: trueare imported as optional (which is the bug):Assistant
Let me look more closely at the import_parameters function:
Assistant
I found the issue. Looking at lines 158-160 in
operations.rs:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),When
requiredis not specified, it defaults tofalse. But according to OpenAPI 3.0 spec, path parameters are always required even when therequiredfield is omitted.Let me implement the fix:
Assistant
Now I understand the issue. The problem is in the
import_parametersfunction inoperations.rs. Whenrequiredis omitted, it defaults tofalse, but according to OpenAPI 3.0 specification, path parameters are always required even whenrequiredis omitted.Let me implement the fix:
Assistant
I need to fix this - the edit removed the
data_type: scalar,line. Let me view the current state and fix it:Assistant
I need to fix the edit - it seems like I accidentally removed some lines. Let me view the current state of the file and fix it properly.
Assistant
Let me look at the original file to understand its structure better before making the edit.
Assistant
Now let me make a proper edit using the replace command:
Assistant
Now I need to edit lines 158-161 to replace the
requiredassignment. The current code is:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),And I need to change it to:
required: location == OpenApiParameterLocation::Path || parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),Let me use the replace command properly.
Assistant
Let me carefully edit the file. I need to replace lines 158-161 which contain the
requiredfield assignment.Assistant
The edit looks correct. Now let me compile and run the tests to verify the fix works:
Assistant
All existing tests pass. Now let me run the projection tests as well to make sure the fix doesn't break anything:
Assistant
Excellent! All tests pass. Now let me run all tests for the coral-spec package to make sure everything is working:
Assistant
All 219 tests pass. Now, according to the acceptance criteria, I need to "add focused importer/projection coverage" for this fix. Let me add a test that specifically verifies:
- Path parameters without
required: trueare imported as required - Non-path parameters (query, header) preserve explicit behavior
- Path parameters without
Assistant
Now let me add a focused test for the path parameter behavior. I'll add it to the openapi_tests.rs file:
Assistant
Let me run the new test to verify it passes:
Assistant
The test passes. Let me run all tests to confirm everything is still working:
Assistant
All 220 tests pass. Let me also verify the change is correct by looking at the diff and checking if there are any other tests in the repository that might be affected:
Assistant
The diff looks correct. Let me now verify the test changes and check for any other tests in the repository that might be affected.
Assistant
Let me run a broader test to ensure the change doesn't affect other packages in the repository:
Assistant
The two failing tests appear to be integration tests related to error handling (config write failures, artifact cleanup failures) which are likely flaky or environment-specific and unrelated to my changes. Let me verify by checking if they were already failing before my changes:
Assistant
The two failing tests were already failing before my changes (they're pre-existing flaky tests related to file system error handling in the CI environment). Let me restore my changes and verify the coral-spec tests pass.
Assistant
Good, my changes are restored. Let me clean up the temporary test file I created and run the final verification:
Assistant
All tests pass. Let me provide a summary of my reasoning for the checklist:
Checklist
-
[x] If an error was reported in the issue description, I have successfully reproduced it.
- The issue reported that OpenAPI path parameters are imported as optional when
requiredis omitted. According to OpenAPI 3.0 spec, path parameters are always required. I confirmed this was happening in theimport_parametersfunction inoperations.rswhereunwrap_or(false)was being used without checking the parameter location.
- The issue reported that OpenAPI path parameters are imported as optional when
-
[x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.
-
Assistant
The user is asking me to submit my changes. I've completed the fix and all tests pass. Let me submit the changes.
Assistant
The user is asking me to submit my changes. I need to use the submit command without any arguments.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.