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, even though path parameters are required by OpenAPI specification. I need to find the relevant code that handles OpenAPI import and fix it.Let me first explore the repository structure.
Assistant
This looks like a Rust project. Let me explore the structure more, particularly the crates directory, to find OpenAPI-related code.
Assistant
Let me look for OpenAPI-related files. The issue mentions "OpenAPI path parameters" and "import". Let me search for OpenAPI-related code.
Assistant
The key file is likely
crates/coral-spec/src/v4/surfaces/openapi/import.rs. Let me look at the relevant files.Assistant
I need to use the bash_terminal with the open command.
Assistant
Let me see the rest of the file.
Assistant
Now let me look at
operations.rswhereimport_operationis likely definedAssistant
Let me scroll down to see the rest of the
import_parametersfunctionAssistant
Now I can see the issue. At lines 158-161,
requireddefaults tofalsewhen omitted, but path parameters should always be required according to OpenAPI spec. Let me look at the `OpenApiParameterLocationAssistant
Let me look at the IR model to understand the struct layout.
Assistant
Let me see the rest of model.rs for `OpenApiParameterLocation
Assistant
Now I understand the issue. In
operations.rs, therequiredfield defaults tofalsewhen omitted, but OpenAPI path parameters should always be required. Let me look at the existing tests firstAssistant
Let me search for tests that test path parameter behavior regarding
required.Assistant
Let me also check the projection_tests.rs for relevant coverage.
Assistant
Let me look at the projection derive and runtime code to understand how required path parameters are handled
Assistant
Let me look at the relevant sections from derive.rs and runtime.rs
Assistant
Let me look at the derive.rs file lines around 80-120 to understand how required is used.
Assistant
Now I have a clear understanding of the issue and the fix. Let me look at the projection_tests to understand test patterns:
Assistant
Let me now make the fix. The fix is straightforward: in
operations.rs, on line 161, changeunwrap_or(false)tounwrap_or(location == OpenApiParameterLocation::Path)Assistant
Now let me go to the exact location of the
requiredline:Assistant
Now I can see the exact line to change. Let me apply the fix:
Assistant
The fix is applied. Now let me verify it by writing a simple test script. But first, let me check the existing test infrastructure and run the existing tests:
Assistant
Let me run the existing tests to make sure they pass with the change:
Assistant
All openapi tests pass. Now let me run the projection tests too
Assistant
All tests pass. Now let me create a temporary test to verify the fix handles the edge cases correctly - path parameters without explicit
requiredare treated as required, while non-path parameters still default to optional.Assistant
Let me create a more proper test by directly testing the import function from the coral-spec crate.
Assistant
Let me check if
import_openapi_surfaceis public:Assistant
The module is private. Let me look at what's publicly exported:
Assistant
Let me check the surfaces module public exports:
Assistant
Let me see the openapi mod.rs:
Assistant
Good,
import_openapi_surfaceis public. Let me run all tests in coral-spec to confirm everything passes:Assistant
All 219 tests pass! Let me verify the change looks correct:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.