ISSUE DESCRIPTION Resolve OpenAPI $ref response objects during DSL v4 import Problem DSL…
- User
ISSUE DESCRIPTION
Resolve OpenAPI $ref response objects during DSL v4 import
Problem
DSL v4 OpenAPI import currently misses valid response objects that are expressed as
$refs.import_responsecallsselect_json_response, andselect_json_responselooks forcontentdirectly on each response object without first resolving$ref.Code references:
crates/coral-spec/src/v4/mod.rs:972crates/coral-spec/src/v4/mod.rs:1290
A valid OpenAPI shape like this is treated as if the operation has no JSON response:
responses: '200': $ref: '#/components/responses/Foo' components: responses: Foo: content: application/json: schema: type: array items: type: objectImpact
The importer falls through to
OutputCardinality::None, which causes otherwise valid read operations to be hidden/dropped from the generated projection catalog. This can make major portions of a real OpenAPI descriptor disappear from DSL v4 sources.Acceptance criteria
- Response
$refs under operation responses are resolved before selecting JSON responses. - Missing or external response refs produce diagnostics consistent with existing schema/parameter ref diagnostics.
- A regression test covers a
200response that references#/components/responses/...and verifies the projection is published.
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. Assistant
Now let's look at
resolve_refand how schema/parameter refs are resolved, to follow the same pattern.Assistant
Good, this confirms the pattern of
continueafterresolve_reffailure with diagnostic already pushed insideresolve_ref. Now let's rewriteresponses.rs.Assistant
Now let's check remaining usages of
schemavariable (since it's now ownedValuenot&Value), and check compile.Assistant
Looks good. Let's build the crate.
Assistant
Builds fine. Now let's find the openapi_tests.rs to add a regression test, and check test_support helpers.
Assistant
This is a great template. Let's add a regression test for
$refresponses, mirroring this test's structure with a$refresponse.Assistant
Now let's append a new test for
$refresponses at the end of file.Assistant
All tests pass including the new regression test. Now let's run the full test suite for the crate to make sure nothing else broke.
Assistant
All 205 tests pass. Let's also run the workspace tests broadly to double check nothing else depends on this behavior, and check for clippy warnings.
Assistant
Let's fix that clippy warning by using
?operator instead ofexpect.Assistant
Clippy warning is gone and all tests pass. Let's view the final diff.
Assistant
Let's merge the two adjacent
implblocks for cleanliness.Assistant
Clean. Let's run cargo fmt check and final tests + clippy once more.
Assistant
Let's apply the fmt fix.
Assistant
Formatting is clean now. Let's do a final full test run to be safe.
Assistant
All checks pass. Let's view the final diff before submitting.
Assistant
Now let me review the checklist items explicitly.
Checklist review:
-
Reproduced the error: I confirmed the issue by reading
select_json_response, which indeed looked forcontentdirectly on each response object without resolving$reffirst — I verified this matches the described bug in the actual code path (now split intosurfaces/openapi/responses.rsrather than the monolithicmod.rsreferenced in the issue, since the repo had since been refactored into submodules). -
Confirmed the fix resolves the error: Added a regression test
importer_resolves_ref_response_objectswith the exact YAML shape from the issue ($refunderresponses.200pointing to#/components/responses/Foo), and verified: (a) the operation's output cardinality is correctly detected asListinstead of falling through toNone/Unknown, (b) noOPENAPI_RESPONSE_SCHEMA_UNRESOLVEDdiagnostic is emitted, and (c) the projection catalog actually publishes aTableprojection for the operation. Test passes.
-
Assistant
-
Edge cases considered:
- Missing response ref (
$refpointing to a non-existent component): handled byresolve_ref, which pushesOPENAPI_REF_NOT_FOUNDdiagnostic and returnsNone, causing that candidate status to be skipped (consistent with how parameter/schema/request-body refs behave elsewhere in the importer). - External response ref (e.g.,
other-file.yaml#/...): handled byresolve_ref, which pushesOPENAPI_EXTERNAL_REF_UNSUPPORTEDand returnsNone, skipping that candidate — consistent with schema/parameter ref handling.
- Missing response ref (
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.