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
I'll start by exploring the repository structure and understanding the relevant code.
Assistant
This file is just the module entry point. The actual import logic is in one of the submodules. Let me find the
import_responseandselect_json_responsefunctions.Assistant
Now let me look at how
resolve_refworks and the existing diagnostics for schema/parameter refs.Assistant
Let me look at the operations.rs to understand how parameters and request body handle
$refresolution.Assistant
Now let me look at the existing OpenAPI tests to understand the test structure.
Assistant
Let me look at the test file more thoroughly, especially tests that check projections and operations output.
Assistant
Let me look at the diagnostics module to understand the Diagnostic structure.
Assistant
Now I have a clear understanding of the issue. The
select_json_responsefunction (line 100 inresponses.rs) looks forcontentdirectly on each response object without resolving$ref. When a response is a$reflike'200': { $ref: '#/components/responses/Foo' }, thecontentlookup fails and the response is skipped.Let me first write a reproduction test to confirm the bug. Let me check the end of the test file.
Assistant
Let me add a regression test to confirm the bug. I'll append it to the test file.
Assistant
Now let me run the test to confirm it reproduces the bug.
Assistant
The test fails as expected —
cardinalityisNone(OutputCardinality::None), confirming the bug. Now let me implement the fix by convertingselect_json_responseinto a method that resolves response$refs.Assistant
Now I'll implement the fix. First, let me update the call site in
import_responseto use the method form.Assistant
Now update the
resolve_refcall to take a reference sinceschemais now owned.Assistant
Now I'll convert the free function
select_json_responseinto a method onOpenApiImporterthat resolves response$refs. Let me view the exact lines first.Assistant
Now let me build and run the regression test to confirm the fix works.
Assistant
The regression test passes now. Let me run the full test suite for the
coral-speccrate to make sure nothing is broken.Assistant
All 205 tests pass. Now let me verify the edge cases (external and missing response refs produce consistent diagnostics) with a temporary test, then remove it.
Assistant
The filter syntax was wrong (cargo uses substring matching). Let me run with a common prefix.
Assistant
Both edge case tests pass — missing and external response refs produce
OPENAPI_REF_NOT_FOUNDandOPENAPI_EXTERNAL_REF_UNSUPPORTEDdiagnostics, consistent with schema/parameter ref handling. Now let me remove the temporary tests, keeping only the required regression test.Assistant
The temp tests start at line 381 (the
#[test]before line 383) and end at line 462. Let me look at lines 380-382 to find the exact start.Assistant
The temp tests are removed. Let me verify the regression test is still intact and run the full test suite once more.
Assistant
All 205 tests pass. Let me run clippy to ensure code quality compliance (the repo has a clippy config).
Assistant
No clippy warnings. Let me check the Makefile for the canonical test command and run the broader test suite to ensure nothing else broke.
Assistant
Let me check for any existing OpenAPI source fixtures in the repo that might use response
$refs, to ensure my change doesn't alter their expected behavior.Assistant
Let me check the projection and manifest tests to ensure they don't test response behavior that my change might affect.
Assistant
These tests all use inline
content(no response-level$ref), so my change leaves their behavior unchanged —resolve_refreturns the value unchanged when there's no$ref. They already passed in the full run. Let me run the broader workspace test to be thorough.Assistant
Two
coral-apptests failed, but they appear unrelated to my change (they test config-write/cleanup rollback failures, likely environment-dependent). Let me confirm they fail on a clean checkout by stashing my changes.Assistant
Confirmed — these two failures occur on a clean checkout (without my changes). They're pre-existing, environment-related failures (filesystem permission mocking doesn't work when running as root). They're unrelated to my change. Let me restore my changes.
Assistant
My changes are restored. Let me do a final review of the complete diff.
Assistant
The diff looks clean. For better style, let me merge the two
impl OpenApiImporter<'_>blocks into one. Let me view the boundary.Assistant
Now there's a single
implblock. Let me rebuild and run the full coral-spec test suite plus clippy to confirm everything is clean.Assistant
All tests pass and clippy is clean. Let me verify formatting with
cargo fmt --checksince the repo likely enforces it.Assistant
Formatting is correct. Let me do a final review of the complete diff.
Assistant
The diff is clean and complete. Let me do a final confirmation run of the full coral-spec test suite.
Assistant
All OpenAPI tests pass, including the new regression test. Let me review the final state of the modified source file once more for correctness.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.