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 first map the repository and locate the v4 OpenAPI importer and projection logic, then reproduce the omitted-
requiredbehavior with the closest existing test setup before making a focused source change. - Assistant
The relevant code is isolated in
coral-spec’s v4 OpenAPI surface importer, with existing importer and projection test modules already present. I’ll read the crate guidance plus parameter construction and projection classification to identify the smallest semantic fix and the exact observable fields. - Assistant
The defect is confirmed at parameter materialization: every omitted
requiredvalue defaults tofalsewithout consideringin: path; that same boolean is propagated into REST bindings and projection derivation. The conforming rule should bepath || declared_required, which also safely treats invalid explicitrequired: falsepath parameters as required while leaving query/header/cookietrue,false, and omitted semantics untouched. Before editing, I’ll run the focused crate tests and build a temporary external reproducer (outside the repository) against the public API so no repository tests are modified. - Assistant
The focused baseline is green (23 v4 tests), so there is no unrelated failure. I’ll now use a
/tmpCargo project to assert both importer and projection outcomes for four inputs: omitted path, explicitly-false path, omitted query, and explicitly-true query. This should fail on the first two requiredness/projection expectations before the fix and directly verify preservation afterward. - Assistant
The external reproducer fails exactly as reported: the omitted path input is optional before projection. I’ll apply the rule at the single normalization point where
locationis already parsed, ensuring all downstream representations receive consistent requiredness. - Assistant
The editor refused the literal replacement because the target line was outside its displayed window; no source change occurred, and the reproducer appropriately still fails. I’ll use the reported exact line range and then rerun formatting plus the reproducer.
- Assistant
The line-range replacement accidentally consumed the adjacent
data_type: scalarfield (the compiler caught it). I’ll restore that field immediately after requiredness, then verify the external importer/projection assertions and the full focused test suite. - Assistant
The reproducer now passes all importer and projection assertions, including invalid explicit-false path handling and unchanged non-path semantics; all 23 existing v4 tests remain green. I’ll check whether importer versioning participates in persisted artifact invalidation (a semantic importer change may require a version bump), then run the entire
coral-specsuite and lint the affected crate. - Assistant
All 219
coral-specunit tests and strict clippy pass. The importer version is embedded in semantic IR fingerprints and explicitly used to reject stale materializations, so this behavioral correction should increment it; otherwise previously generated optional-path artifacts can remain accepted and preserve the bug. I’ll inspect recent version history/convention, then bump only if history confirms semantic changes use this mechanism. - Assistant
History shows the version was introduced specifically as a semantic compatibility marker, and validation rejects mismatches. I’ll increment
openapi-v2toopenapi-v3so installed v4 sources cannot silently reuse buggy IR, then run targeted materialization tests incoral-appin addition tocoral-spec; I’ll first confirm no tests or fixtures hard-code the old marker. - Assistant
The semantic version bump is compatible: all 219 spec tests and 5 materialization tests pass, confirming stale-artifact validation still works. Final checklist:
- Reproduced the reported error. A temporary external fixture with an omitted
requiredpath parameter panicked because the imported input was optional. - Confirmed the fix resolves the error. The same fixture now verifies omitted and explicit-false path parameters are required in both semantic IR and generated projections.
- Considered edge cases. The fixture also confirms omitted query parameters remain optional and explicit-true query parameters remain required; path-level normalization propagates consistently into REST bindings and projections. The importer compatibility marker is bumped to invalidate stale buggy artifacts.
- Ran affected existing tests. The focused v4 tests (23), full
coral-spectests (219), strictcoral-specclippy, formatting checks, and materialization tests (5) all pass.
- Reproduced the reported error. A temporary external fixture with an omitted
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.