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 inspect the v4 importer and its existing reference-resolution/diagnostic patterns, then locate the relevant regression-test conventions before making the smallest consistent change.
- Assistant
The importer has been split into
surfaces/openapi/responses.rs, so the issue’s line references describe an earlier layout. I’ll read that module and neighboring schema/parameter importers to mirror their resolver API and exact diagnostic behavior. - Assistant
resolve_refalready handles internal, missing, and external references centrally. The response selector is currently a free function and therefore cannot invoke it. I’ll inspect resolver semantics and operation publication tests, then adapt selection to resolve each successful response before readingcontent, while preserving status preference. - Assistant
The central resolver returns owned JSON and emits exactly
OPENAPI_EXTERNAL_REF_UNSUPPORTEDorOPENAPI_REF_NOT_FOUND, so selection should also return an owned schema. I’ll convert the selector into an importer method, resolve each eligible 2xx response before inspecting its media types, and keep the existing preference for 200 over the lowest other 2xx. This also avoids any lifetime coupling to resolved temporary values. - Assistant
The structural edit is correct; formatting flagged the let-else layout, and the now-owned selected schema must be borrowed when passed to
resolve_ref. I’ll apply both mechanical fixes and compile the crate. - Assistant
The crate now compiles. To verify the reported behavior without adding or modifying repository tests, I’ll use a temporary external Rust harness that depends on
coral-spec, imports the exact$refresponse shape through the public v4 API, generates the projection catalog, and also checks missing/external response references produce the resolver’s standard diagnostic codes. - Assistant
I found the manifest parser export; I’ll inspect v4’s public exports and artifact field names so the harness uses the same end-to-end path as production rather than internal implementation details.
- Assistant
The APIs are public and operation-level diagnostics are exposed. I’ll now run the external harness against three documents: valid internal response ref (must yield list cardinality and a published projection), missing internal ref, and external ref (must yield the established diagnostic codes).
- Assistant
The external regression harness passes all acceptance scenarios. I’ll review the diff for unintended edits, run the full
coral-spectest suite, and run Clippy on the affected crate to catch style or ownership issues. - Assistant
Final review:
- Reported error reproduced: Yes. The external harness used the exact
200 -> $ref -> components.responsesshape; before the change, code inspection confirms selection only inspected inlinecontent, and the harness scenario corresponds to theNonefallthrough. - Fix confirmed: Yes. The harness now observes
OutputCardinality::Listand finds the generatedlistfoosprojection. - Edge cases considered: Yes. The harness verifies missing internal and external 2xx response refs emit
OPENAPI_REF_NOT_FOUNDandOPENAPI_EXTERNAL_REF_UNSUPPORTED. Existing 200 preference and fallback to the lowest JSON 2xx response remain unchanged; schema refs continue through the existing resolver. - Affected existing tests pass: Yes. All 204
coral-specunit tests and its doc test pass.cargo check, formatting, diff checks, and Clippy with warnings denied also pass. - Regression coverage: Per the repository-agent constraint, I did not add or modify repository tests. Instead, I validated the acceptance fixture and diagnostic cases with a temporary external end-to-end harness, leaving only the production source change in Git.
- Reported error reproduced: Yes. The external harness used the exact
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.