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
I'll start by exploring the repository structure to understand the codebase and locate the relevant files mentioned in the issue.
- Assistant
Let me look at the specific file mentioned in the issue:
crates/coral-spec/src/v4/mod.rs. First, let's check lines 972 and 1290 to understand the current implementation. - Assistant
Let me use the open command to look at the file.
- Assistant
The main module is just a re-export file. The actual logic must be in the
surfacesmodule. Let me explore the directory structure more: - Assistant
Let me explore the responses and operations files to understand the issue better:
- Assistant
Let me scroll down to see the
select_json_responsefunction: - Assistant
Now I need to understand how the importer resolves
$refreferences. Let me look at theresolve_refmethod and how it's used elsewhere: - Assistant
Let me look at the import.rs file to understand the resolve_ref method:
- Assistant
Let me scroll down to see the complete resolve_ref method:
- Assistant
Let me look at the operations.rs file to see how responses are currently imported:
- Assistant
Let me look at the existing tests to understand how responses are tested:
- Assistant
Let me look at the openapi_tests.rs file to understand how tests are structured:
- Assistant
Let me scroll down to see more of the test file:
- Assistant
Let me see the full
select_json_responsefunction: - Assistant
Now I'll create a reproduction script to confirm the issue:
- Assistant
Let me run the existing tests first to see if there are any related tests:
- Assistant
Let me look at that test to see if it's related to response refs:
- Assistant
The file seems to have moved or is not found with that path. Let me check the actual file path.
- Assistant
We're in the coral-spec directory. Let me use the absolute path.
- Assistant
Let me check how the importer handles other $ref resolution patterns:
- Assistant
Let me create a proper reproduction script:
- Assistant
Let me add this test to the openapi_tests.rs file to see if it fails:
- Assistant
Let me run this test to see if it fails:
- Assistant
Perfect! The test fails as expected, confirming the issue. Now I need to fix it. Let me look at the full responses.rs file to understand the structure better:
- Assistant
Let me check if
select_json_responseis used elsewhere: - Assistant
Now I understand the issue. The
select_json_responsefunction doesn't resolve$refon response objects. I need to modify it to resolve response refs before checking forcontent. Let me implement the fix: - Assistant
Let me see the rest of the file:
- Assistant
Now I understand the issue clearly. The
select_json_responsefunction doesn't resolve$refon response objects before checking forcontent. I need to make it a method onOpenApiImporterso it can resolve refs. Let me implement the fix: - Assistant
Now I need to update the call in
import_responseto useself.select_json_response(...)instead ofselect_json_response(...): - Assistant
Now I need to update the call to
select_json_responseto useself.select_json_response(...)and pass the required parameters: - Assistant
The edit command needs a closing EOF. Let me fix this.
- Assistant
Now let me check if the code compiles:
- Assistant
Now
select_json_responsereturns an ownedValueinstead of a&Valuereference. The call toself.resolve_ref(schema, ...)on line 42 now passes an ownedValuebutresolve_refexpects&Value. I need to borrowschema: - Assistant
I need to close the EOF properly.
- Assistant
Now let me check if it compiles:
- Assistant
Great! It compiles. Now let me run the test to see if it passes:
- Assistant
Excellent! The test passes. Now let me run all the existing tests to make sure I didn't break anything:
- Assistant
All 205 tests pass. Now let me clean up the duplicate
impl OpenApiImporter<'_>blocks and merge them: - Assistant
Let me see the second impl block and merge them:
- Assistant
Now let me also add a test for missing/external response refs to ensure diagnostics are emitted:
- Assistant
Let me run this test:
- Assistant
Let me run all tests again to make sure everything still works:
- Assistant
All 206 tests pass. Now let me clean up. First, let me remove the test code I added to openapi_tests.rs (since the system prompt says not to add tests to the repository):
- Assistant
Let me see the rest of the diff:
- Assistant
Now let me remove the test code I added and restore the original file:
- Assistant
Now let me check the current state of the code and verify the fix is correct:
- Assistant
Let me run all the tests one more time to make sure everything still works:
- Assistant
All 204 tests pass. Now let me create a temporary script to verify the fix works as expected:
- Assistant
Let me also verify that the fix handles the exact scenario described in the issue by creating a more comprehensive test:
- Assistant
Let me clean up the temporary files:
- Assistant
Let me run a final check to make sure the code is correct:
- Assistant
Perfect! All tests pass. Now let me create a summary of the changes I made:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.