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
Now let's modify the
requiredcomputation to force true for Path location regardless of explicit field (per OpenAPI spec, path params must always be required=true, but let's check acceptance criteria: "preserve explicit behavior for non-path parameters" - meaning explicit required field for non-path is preserved, but for path it should always be true even if explicit says false? Let's check the linked PR context for clarity).Assistant
Now let's implement the fix - path parameters are always required per OpenAPI spec.
Assistant
Now let's check that OpenApiParameterLocation implements PartialEq (yes it does per derive). Let's build.
Assistant
Build succeeded. Now let's check existing tests related to this behavior, and add focused test coverage per acceptance criteria.
Assistant
Let's look at a test that checks
inputson an operation for required flags, so I can model my new test after it.Assistant
Now let's find the end of the file to append a new test.
Assistant
Now let's add a test for path parameters with omitted required field being treated as required, and verify query parameter with omitted required stays optional.
Assistant
Now let's check projection tests to add focused projection coverage per acceptance criteria.
Assistant
Let's find a test dealing with ProjectionInput and required column to model a new projection test after.
Assistant
Now let's write a projection test verifying
ProjectionInput.requiredis true for a path parameter with omittedrequired, checking it viaprojection.inputs.Assistant
Now let's add a focused projection test appended to projection_tests.rs.
Assistant
Good, "items/get" -> "items_get". That matches. Now let's run tests.
Assistant
All new tests pass. Now let's run full test suite for coral-spec to make sure nothing broke.
Assistant
All 222 tests pass. Let's also check other crates that might depend on this behavior (e.g., coral-cli, coral-app) for broader regression testing.
Assistant
Build succeeds across the workspace. Let's check git diff for final review.
Assistant
Let's do a final diff review.
Assistant
This resolves the issue clearly. Now let's run clippy to make sure no lint issues were introduced (since strict linting may be part of CI).
Assistant
No clippy warnings. Now let's review the full checklist.
Assistant
The changes are minimal, targeted, and well-tested. Let's go through the checklist.
Checklist Review
1. If an error was reported in the issue description, I have successfully reproduced it. The issue describes a behavioral misclassification (not a crash/error): OpenAPI path parameters imported as optional when
requiredis omitted. I reproduced this by writing a test (importer_treats_path_parameters_as_required_when_omitted) with a path parameter lackingrequired, confirming that before my fix it would be classified asrequired: false(verified by inspecting the pre-fix code atoperations.rs:158-161, which unconditionally defaulted tounwrap_or(false)regardless of location).Assistant
Let me directly verify by reverting only the fix (keeping the new tests) to confirm the test fails without the fix — proving genuine reproduction and validation.
Assistant
Confirmed the bug is reproduced (test fails without fix). Now reapply the fix.
Assistant
Fix confirmed to resolve the failing test.
2. If an error was reported in the issue description, I have confirmed that my fix resolves the error. Verified above — the test fails on the pre-fix code and passes after reapplying the fix.
Assistant
3. I have thought about edge cases and made sure my fix handles them as well.
Edge cases considered:
- Path parameter with
required: trueexplicitly set → still required (covered, unaffected). - Path parameter with
required: falseexplicitly set (technically invalid per OpenAPI spec, since spec mandatesrequiredmust betruefor path params) → now forced totrue, which is the spec-compliant behavior; this is intentional since OpenAPI itself states path parameters MUST be required. - Non-path parameters (query, header, cookie, body) with omitted
required→ still default tofalse(preserved, verified byverbosein tests). - Non-path parameters with explicit
required: true/false→ preserved (covered byimporter_preserves_explicit_required_for_non_path_parameters). - Downstream projection generation correctly reflects the corrected
requiredflag (covered byprojection_marks_path_parameters_required_when_omitted), ensuring path parameters are not misclassified as optional SQL filters, which was the core concern in the issue.
- Path parameter with
Assistant
Good —
RestParameterBinding.requiredis derived frominput.requiredafter the fix, so the correction flows through to the runtime execution layer as well, ensuring consistency across the whole pipeline.Assistant
All downstream consumers of
input.required(SQL filter/nullability logic, projection naming, runtime schema generation, REST execution bindings) automatically benefit from the fix since it's set at the single source of truth (the importer).4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
Assistant
Let's also run the broader workspace tests for crates that consume these projections (coral-app, coral-cli) to double check for regressions from this change in end-to-end scenarios.
Assistant
These tests are feature-gated and not directly relevant to this fix (they concern CLI e2e infra, not OpenAPI import specifics). The coral-spec test suite is the appropriate and sufficient scope for this change; I've already confirmed all 222 tests there pass, plus a full workspace build succeeds.
Assistant
Confirmed these two test failures are pre-existing and unrelated to my change (they fail identically even without my modifications — likely environment-specific flakiness related to fault-injection simulations). This satisfies the checklist item since I confirmed my change didn't cause any regressions.
Assistant
All checklist items are satisfied. The final change set is minimal, targeted, and well-verified:
Summary
Fix: In
crates/coral-spec/src/v4/surfaces/openapi/operations.rs, theimport_parametersfunction now forcesrequired: truefor any parameter locatedin: path, regardless of whether the OpenAPIrequiredfield is present, explicitlyfalse, or omitted — since path parameters are always required per the OpenAPI specification. Non-path parameters (query, header, cookie, body) continue to use their explicitrequiredvalue, defaulting tofalsewhen omitted.Tests added:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.