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 repository structure, the referenced v4 importer functions, and nearby tests to understand existing
$refresolution and diagnostic conventions before making a focused change. - Assistant
The implementation has been refactored from the issue’s cited line numbers into
surfaces/openapi/responses.rs. I’ll inspect that module, the importer context and its existing reference resolver, plus the OpenAPI fixture/test layout so the fix follows current architecture rather than duplicating logic. - Assistant
resolve_refis already used for schemas, parameters, and request bodies, so response objects should pass through the same method before content selection. I’ll now examine its exact semantics and diagnostics, operation publication rules, and existing OpenAPI tests to determine the cleanest lifetime-safe API and a regression assertion. - Assistant
The resolver emits the required existing codes (
OPENAPI_EXTERNAL_REF_UNSUPPORTEDandOPENAPI_REF_NOT_FOUND) and returns an owned clone, which avoids borrow complications. The likely change is to make response selection an importer method (or resolve candidates inimport_response) and resolve each successful response object before examiningcontent. I’ll inspect all current tests and Cargo test naming to add no tests per instruction! Important developer says under no circumstances modify/add tests. Acceptance asks regression but system says don't. We cannot tests modifications. We'll use temporary reproduction. Need understand behavior diagnostics desired. - Assistant
Before editing, I’ll reproduce the reported failure with a temporary standalone Cargo program outside the repository. It will call the public v4 import and catalog APIs using the exact referenced-response shape, print cardinality/projection count, and avoid modifying repository tests.
- Assistant
The reproduction confirms the core bug (
cardinality=None). This repository’s catalog retains a hidden projection rather than omitting it entirely, so I’ll enhance the temporary probe to record visibility, then implement response-object resolution while preserving response-selection precedence and schema-resolution behavior. - Assistant
I’ll change
select_json_responseinto anOpenApiImportermethod that invokes the shared resolver on every numeric 2xx response before checking media content. Because resolution returns an ownedValue, selected schemas will also be owned; the later schema resolver can consume them by reference exactly as before. This naturally emits existing missing/external-ref diagnostics and permits fallback to another valid 2xx candidate. - Assistant
The code change is in place; formatting check found only rustfmt’s preferred
let-elselayout. I’ll apply formatting, inspect the resulting diff, and run the standalone reproduction to verify cardinality and publication change. - Assistant
The exact case now imports as
Listand its projection isPublished, satisfying the functional acceptance criterion. Next I’ll exercise edge cases in the temporary probe: missing and external response-object refs must emit the shared resolver’s established diagnostics, and an unresolved200should not prevent selection of a valid201. - Assistant
The edge-case probe confirms exact existing diagnostic codes and correct fallback behavior. I’ll now run the affected crate’s complete test suite and Clippy with workspace lint policy, then inspect for unintended files or formatting issues.
- Assistant
All 204
coral-spectests, its doctest, Clippy with warnings denied, and diff checks pass. I’ll perform a final source/diff review to ensure the patch is minimal, no tests or unrelated files were changed, and the selected response still preserves200preference and lowest-2xx fallback.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.