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.
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, only submits currently unstaged changes because it uses to get the changes that need to be submitted. Assistant
Let me start by understanding the repository structure and the issue. The issue says:
- DSL v4 OpenAPI import misses valid response objects expressed as
$refs import_responsecallsselect_json_response, andselect_json_responselooks forcontentdirectly on each response object without first resolving$ref- Files to look at:
crates/coral-spec/src/v4/mod.rs:972andcrates/coral-spec/src/v4/mod.rs:1290
Let me explore the repository structure first.
- DSL v4 OpenAPI import misses valid response objects expressed as
Assistant
Let me look at the key file mentioned in the issue.
Assistant
That's surprising - let me look at the full file.
Assistant
The code is in submodules. Let me look at the surfaces module (likely has
import_openapi_surface) and the ir module.Assistant
The modules could be directories. Let me check.
Assistant
Now let me look at the key files. Let me start with the responses module and the import module
Assistant
I can see the issue clearly. The
select_json_responsefunction looks forcontentdirectly on response objects without resolving$refs first. Let me look at howresolve_refworks and how schema refs are resolved.Assistant
Now let me look at the existing tests to understand the testing patterns:
Assistant
Let me also look at operations.rs and schemas.rs for completeness
Assistant
Now let me look at schemas.rs
Assistant
Now I have a full understanding of the issue and the codebase. Let me now create a script to reproduce the error first, then fix
Assistant
Let me now look at the test_support module and understand how tests validate the projection catalog
Assistant
Let me also quickly look at how diagnostics are defined to understand the patterns
Assistant
Let me first build the project to ensure it compiles and run existing
Assistant
Good, it builds. Let me run existing tests in the coral-spec crate to see them pass
Assistant
All 204 tests pass. Let me now create a reproduction script to confirm the issue exists
Assistant
Now let me temporarily include this test to reproduce the bug
Assistant
Let me temporarily add the repro_test module to mod.rs and run it.
Assistant
I need to adjust the import. Let me look at how other tests import this function.
Assistant
Let me fix the reproduction test imports
Assistant
The bug is confirmed:
OutputCardinality::Noneis returned when response uses$ref. Now let me implement the fix. Let me edit the responses.rs file.Assistant
Let me use the
opencommand correctly.Assistant
Let me see the full file
Assistant
Now I'll implement the fix. I need to:
- Convert
select_json_responseto a method onOpenApiImporterthat resolves$refs - Update the call in
import_response
Let me first replace the standalone function with a method inside the impl block.
- Convert
Assistant
The method is outside the
implblock (after the closing}on line 98). I need to move it inside the impl block. Let me fix this.Assistant
I see there's a duplicate
fn classify_response_schemaat lines 134 and 136. Let me fix thisAssistant
There's still a duplicate. Let me fix it properly.
Assistant
Good, the structure looks correct now. Now I need to update the call in
import_responseto useself.select_json_responseand pass the additional arguments. Let me also update theresolve_refcall to take a reference sinceschemais nowValue.Assistant
Now I need to update line 42 to pass
&schemainstead ofschemasinceresolve_reftakes&Value:Assistant
Now let me try building to check for compilation
Assistant
It compiles. Now let me run the reproduction test to confirm the fix works
Assistant
The reproduction test passes! Now let me run all existing tests to make sure I haven't broken anything
Assistant
All 205 tests pass. Now let me clean up the temporary reproduction test and add a proper test to
openapi_tests.rs. First, let me remove the temp test module.Assistant
Now remove the temporary module from mod.rs:
Assistant
Let me verify mod.rs
Assistant
Good. Now let me add a proper regression test to
openapi_tests.rs. Let me open the fileAssistant
Let me see the end of the
Assistant
Let me see the rest of the file:
Assistant
Now I'll add a regression test at the end of
openapi_tests.rs. Let me add it after line 323:Assistant
There's a duplicate line 323. Let me fix it:
Assistant
Good. Let me now build and run all tests to verify everything works
Assistant
All tests pass. But let me also optimize the order of checks in
select_json_response- I should check the status code before resolving refs to avoid unnecessary diagnostics for non-2XX status codes:Assistant
Let me open the responses file
Assistant
Now let me fix the order of checks
Assistant
Good. Now let me run all tests again to confirm everything still
Assistant
All 205 tests pass. Let me verify the final state of both modified
Assistant
Let me clean up the extra blank line and check if there are other related files that might need changes
Assistant
Let me also check document.rs and run a broader search to ensure there aren't other places needing fixes
Assistant
Let me search for any other places that might need similar fix:
Assistant
Good, the fix is complete and isolated to the right file. Let me also quickly check the
surfaces/openapi/mod.rsfile forAssistant
Let me run the full test suite one final time and check git diff
Assistant
Let me check the git diff:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.