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.
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:
- Assistant
I’ll first inspect the v4 importer, its existing reference-resolution helpers, and nearby regression tests so the response fix follows established diagnostics and conventions. Then I’ll reproduce with the narrowest relevant test path, implement the change, and run focused plus broader tests.
- Assistant
The combined command unexpectedly returned no visible output, so I’ll verify the repository paths and file size before reopening the relevant regions with the provided editor command.
- Assistant
The importer has since been split out of
mod.rs; I’ll locateimport_responseand all reference resolvers across the crate, then inspect the matching implementation and tests. - Assistant
ripgrepis unavailable in this environment, so I’ll use recursivegrepto find the same symbols. - Assistant
I found the split implementation. Next I’ll inspect the generic resolver, response-selection logic, operation flow, and OpenAPI test helpers to understand lifetimes and expected diagnostic assertions before editing.
- Assistant
The generic
resolve_refalready emits exactly the requiredOPENAPI_EXTERNAL_REF_UNSUPPORTEDandOPENAPI_REF_NOT_FOUNDwarnings. The clean fix is to make response selection an importer method, resolve each successful response object before inspectingcontent, and return an owned schema because the resolved response is owned. This preserves 200-preference/fallback behavior and lets unresolved candidates be skipped while retaining diagnostics. I’ll inspect complete focused tests and projection generation APIs, then run the current tests as the baseline reproduction. - Assistant
The existing focused suite has no response-object
$refcase, but its importer tests establish the pre-change baseline. I’ll run that suite now; the reported shape’s failure is also directly confirmed by the current selector readingresponse.get("content")on the raw{"$ref": ...}object, which necessarily returnsNoneand yieldsOutputCardinality::None. - Assistant
I’ll now change only
responses.rs: invoke selection throughself, resolve each 2xx response with the shared resolver before examining media content, and clone the selected schema into the candidate list. This keeps schema resolution as a separate subsequent step and avoids introducing response-specific diagnostic behavior. - Assistant
The structural change is in place. I’ll compile and run the focused importer tests now; this will catch any owned-schema borrowing adjustments and ensure existing response selection behavior remains intact.
- Assistant
As anticipated from changing the selected schema to owned data, the compiler requires an explicit borrow when passing it to
resolve_ref. I’ll apply that minimal correction and rerun the focused suite. - Assistant
The existing focused suite passes. To verify the exact acceptance case without modifying or adding repository tests, I’ll create a temporary external Rust crate under
/tmpthat depends oncoral-spec. It will import the reported#/components/responses/Foodocument, assert list cardinality and a published projection, then check missing and external response references emit the shared resolver diagnostic codes. - Assistant
The temporary acceptance harness passed all three checks: the referenced array response produces
OutputCardinality::List, its operation appears in the projection catalog, and missing/external response refs produceOPENAPI_REF_NOT_FOUND/OPENAPI_EXTERNAL_REF_UNSUPPORTED. I’ll now run the entirecoral-spectest suite and package clippy, then review the final diff and working tree for unintended changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.