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:
yamlresponses: '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 use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. Assistant
Let me start by understanding the issue. The problem is that when importing OpenAPI v4 specifications, the code doesn't resolve
$refreferences in response objects before looking for JSON content. This means that responses defined as$refto#/components/responses/...are not being processed correctly.Let me first explore the repository structure and understand the codebase.
Assistant
I found the Rust crates in the repository. Let me look at the specific file mentioned in the issue.
Assistant
The file structure doesn't show
mod.rsas having the lines mentioned. Let me check the main file structure more carefully.Assistant
The mod.rs is only 54 lines. The actual implementation is probably split across multiple files. Let me look at the module structure and find the
import_responseandselect_json_responsefunctions mentioned in the issue.Assistant
Now I understand - the functions are in
/coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs. Let me look at that file.Assistant
Now I understand the issue. The
select_json_responsefunction looks forcontentdirectly on each response object, but when a response uses$ref, the content is in the referenced response, not on the$refobject itself.Let me look at how other refs are resolved in the codebase to understand the pattern:
Assistant
Let me look at the
resolve_reffunction to understand how refs are resolved.Assistant
Now let me look at the existing tests to understand how tests are structured:
Assistant
Now let me look at the test support module and understand the existing test infrastructure:
Assistant
Assistant
Let me use the correct command format.
Assistant
Now I have a good understanding of the codebase. Let me first run the existing tests to confirm they pass, then create a reproduction test case and implement the fix.
Assistant
All tests pass. Now let me create a reproduction script to confirm the bug:
Assistant
Let me add a test to confirm the bug exists, then fix it:
Assistant
The user wants me to run the test I just added to confirm it fails (proving the bug exists), then fix it.
Assistant
The test confirms the bug exists. The response
$refis not being resolved, so the cardinality isNone. Now let me implement the fix.The issue is in
select_json_response- it looks forcontentdirectly on each response object without resolving$reffirst. I need to modify it to:- Take the document and diagnostics parameters
- Resolve
$refon each response object before looking for content - Generate appropriate diagnostics for unresolved refs
Assistant
Now I'll implement the fix. I need to modify
select_json_responseto resolve response$refbefore looking for content. The function needs access to the document and diagnostics for ref resolution.Assistant
The user wants me to run the test to verify the fix works.
Assistant
I need to borrow the schema value since
resolve_refexpects a reference. Let me fix that:Assistant
The user wants me to run the test again to confirm the fix works.
Assistant
The test passes. Now let me run all tests to make sure I haven't broken anything:
Assistant
All 205 tests pass, including my new test. Let me review my changes more carefully and think about edge cases. I notice that my
resolve_response_reffunction uses"unknown"as the surface_id, which isn't ideal. Let me fix that to use the proper surface context:Assistant
I need to pass the
surface_idtoresolve_response_refinstead of using "unknown". Let me update the function signature:Assistant
I need to use the bash_terminal command instead of edit since the tool call wasn't properly formatted.
Assistant
The user wants me to run the tests again to verify the fix still works after my refactoring to properly pass surface_id to the diagnostic.
Assistant
All 205 tests pass, including my new test. Now let me think about edge cases and add more comprehensive tests:
- External refs (not starting with
#/) - should produce a warning diagnostic - Missing refs (pointing to non-existent paths) - should produce a warning diagnostic
- Multiple responses where some use
$ref- should still work correctly
Let me add tests for these edge cases:
- External refs (not starting with
Assistant
The user wants me to run the new edge case tests I just added to verify they work correctly. Let me run all the openapi tests to confirm.
Assistant
All 9 importer tests pass, including my new edge case tests. Let me run the full test suite to confirm everything works:
Assistant
All 208 tests pass. Let me review the final changes I've made to ensure everything is correct before submitting:
Assistant
The user wants me to submit my changes. I've completed the fix and all tests pass. Let me submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.