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:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /coral, current file: none) bash-$
Assistant
Let me start by understanding the repository structure and the issue at hand. The issue is about resolving OpenAPI
$refresponse objects during DSL v4 import. Let me explore the codebase first.Assistant
Let me explore the structure more, especially the files mentioned in the issue.
Assistant
The user seems to be pointing out that I made an error in my function call. Let me correct this - I need to use the proper arguments for the open command, which should be
FILEandLINE_NUMBERas separate arguments, notfileandline.Assistant
The arguments seem case-sensitive. Let me try lowercase.
Assistant
Let me try using the bash terminal to view the file:
Assistant
The output wasn't shown. Let me try a different approach:
Assistant
The file is only 54 lines. The issue mentions line 972 and 1290, so the actual code must be in the sub-modules. Let me look at the surfaces/openapi files:
Assistant
I see there's a
responses.rsfile. Let me look at it along with the operations file:Assistant
Now I can clearly see the problem. In
select_json_response, the function iterates over responses and looks forcontentdirectly on each response object. If a response is a$ref, it won't have acontentfield, so the function skips it.Let me also look at the
import.rsfile to understand how refs are resolved:Assistant
Now I understand the
resolve_refmethod. It resolves$refpointers within the document. Let me also look at the operations file and the tests:Assistant
Now let me look at the existing tests to understand how to write a regression test:
Assistant
Now I have a clear understanding of the codebase and the issue. Let me also look at the
schemas.rsfile to see how they handle refs for schemas (as a reference pattern):Assistant
Now I have a complete picture. Let me now write a test script to reproduce the issue:
Assistant
Good, all tests pass. Now let me create a script to reproduce the issue first, demonstrating that response
$refs are not resolved:Assistant
Let me look at how to write a test within the existing test file. I'll add a failing test first:
Assistant
Now let me understand the issue better. The
select_json_responsefunction inresponses.rsneeds to be modified to resolve$refbefore looking forcontent. However,select_json_responseis a standalone function that doesn't have access toself(the importer). So I need to refactor this.Let me look at how
import_responsecallsselect_json_response:Assistant
The issue is clear:
select_json_responsetakes a reference to the responses map and looks forcontentdirectly on each response object. When the response is a$ref, there's nocontentfield.I need to change this function so it can resolve refs. Since ref resolution needs access to
self(theOpenApiImporter), I have two options:- Move
select_json_responseinto theOpenApiImporterimpl block and give it access toself.documentfor ref resolution. - Pass
selftoselect_json_responseor change the approach.
The cleanest approach is to make
select_json_responsean inherent method onOpenApiImporterthat takes&selfso it can resolve refs and emit diagnostics.Let me now implement the fix:
- Move
Assistant
Now I understand the code. The key change needed is:
- Move
select_json_responseinto theOpenApiImporterimpl block so it has access toself.resolve_ref - In
select_json_response, before looking forcontent, resolve any$refon the response object - Emit diagnostics for missing or external refs (consistent with schema/parameter ref diagnostics)
The function signature also needs to change - it currently returns
Option<(u16, String, &Value)>with a borrowed&Value. Since we need to resolve refs (which creates ownedValues), we need to return owned values.Let me implement the fix:
- Move
Assistant
Now let's verify the code compiles and run the existing tests:
Assistant
All 204 tests pass. Now I need to add a regression test that covers the specific case mentioned in the issue - a
200response that references#/components/responses/.... Let me add the test:Assistant
Now let's run the new tests to confirm they pass:
Assistant
All three new tests pass. Now let me run the full test suite to make sure everything still works:
Assistant
All 207 tests pass (204 original + 3 new). Let me verify the changes I made:
Assistant
I've completed the fix for the OpenAPI
$refresponse objects issue. Let me verify my checklist:Checklist Review
-
If an error was reported in the issue description, I have successfully reproduced it.
- ✅ I analyzed the code and confirmed that
select_json_responseinresponses.rslooks forcontentdirectly on each response object without first resolving$ref, which causes response refs to be skipped.
- ✅ I analyzed the code and confirmed that
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- ✅ I modified
select_json_responseto be a method onOpenApiImporterso it can callresolve_refbefore looking forcontent. The new testimporter_resolves_response_ref_in_componentsconfirms that a200response referencing#/components/responses/...is now properly resolved and the projection is published.
- ✅ I modified
-
I have thought about edge cases and made sure my fix handles them as well.
- ✅ Added tests for:
- Missing response refs: Produces
OPENAPI_REF_NOT_FOUNDdiagnostic (consistent with existing schema/parameter ref diagnostics) - External response refs: Produces
OPENAPI_EXTERNAL_REF_UNSUPPORTEDdiagnostic (consistent with existing behavior)
- Missing response refs: Produces
- Both edge cases skip the unresolvable response and fall through to
OutputCardinality::None
- ✅ Added tests for:
-
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
- ✅ All 207 tests pass (204 original + 3 new regression tests)
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →