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 codebase to fix this issue.
Assistant
Let me look at the relevant file mentioned in the issue:
Assistant
That seems short. Let me check if there are multiple v4 modules or if the issue refers to a different location.
Assistant
The file is only 54 lines, so the line numbers must be in a different file. Let me search for the functions mentioned in the issue.
Assistant
Now let me check the responses.rs file and look for
select_json_response:Assistant
Let me examine the responses.rs file to understand the current implementation:
Assistant
Let me use the open command correctly.
Assistant
Let me just use cat to read the file instead.
Assistant
Now I understand the issue. The
select_json_responsefunction doesn't resolve$refreferences before looking forcontent. Let me look at how the importer resolves refs:Assistant
Let me look at the import.rs file to understand how resolve_ref works.
Assistant
Now I understand the full picture. The
select_json_responsefunction at line 100 needs to be modified to:- First resolve
$refon the response object before looking forcontent - The
import_responsefunction needs to be able to resolve the response$refand then pass the resolved response to the selection logic
Let me look at the existing operations.rs to understand how the import flows:
- First resolve
Assistant
Now I understand the issue. The
select_json_responsefunction doesn't resolve$refon response objects before looking forcontent. Let me examine existing tests and then create a reproduction script.Assistant
Now I need to look at the test_support file to see how to set up a test OpenAPI document:
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/test_support.rs </tool_call>
Assistant
Let me read the test_support.rs file to understand how tests work.
Assistant
Let me check the openapi_tests.rs as well:
Assistant
Now let me create a reproduction script to confirm the bug:
Assistant
Let me first check how to build and test this project:
Assistant
Let me run the existing tests first to understand the baseline:
Assistant
The build is taking a while. Let me wait for it to finish.
Assistant
Good, all tests pass. Now let me write a test to reproduce the bug:
Assistant
Now let me add this test to the existing openapi_tests.rs file to confirm the bug:
Assistant
Now let me run the new test to confirm the bug:
Assistant
Good, I've confirmed the bug. The test fails because the response
$refis not being resolved, resulting inOutputCardinality::None.Now let me understand the issue more deeply and implement the fix. The
select_json_responsefunction looks forcontentdirectly on each response object, but when a response is a$ref, the response object contains only{"$ref": "..."}and nocontent. We need to resolve the$reffirst.Assistant
Now I understand the issue clearly. The
select_json_responsefunction looks forcontentdirectly on each response object, but when a response is a$ref, it only contains{"$ref": "..."}withoutcontent. I need to resolve$reffirst.The cleanest fix is to modify
import_responseto pre-resolve response objects before passing them toselect_json_response, and add proper diagnostics for missing/external refs.Assistant
The replace command failed. Let me try a different approach - I'll view the file and use edit to make the changes.
Assistant
Let me write the complete file with the fix:
Assistant
Wait, I need to reconsider my approach. The
resolve_responsesfunction I wrote doesn't actually resolve refs because it doesn't have access to the document. Let me fix this properly - theimport_responsemethod has access toself.documentviaOpenApiImporter, so I should use that.Assistant
Now let me run the test to see if my fix works:
Assistant
The test passes. Now let me run all the v4 tests to make sure I haven't broken anything:
Assistant
All tests pass. Now I need to verify the full 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. - Need to test this
- A regression test covers a
200response that references#/components/responses/...and verifies the projection is published. - Need to enhance the test
Let me enhance the test to be more comprehensive:
- Response
Assistant
The user wants me to run all the new tests I just added to make sure they all pass. Let me execute the tests for the openapi_tests module.
Assistant
All new tests pass. Let me run all v4 tests to confirm everything still works:
Assistant
All 23 v4 tests pass, including 6 new tests I added. Let me run the full test suite for the coral-spec crate to make sure nothing else is broken:
Assistant
All 210 tests pass. Let me verify my changes by viewing the diff:
Assistant
Let me do a final comprehensive verification of my changes before submitting:
Assistant
All 210 tests pass, including the 6 new tests I added. Let me verify the final state of the changed files and then submit.
Assistant
The user wants me to submit my changes. I've completed the fix and all tests pass. Let me submit the changes now.
Assistant
The user wants me to submit the changes. I need to call the submit command with the correct syntax.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.