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.
Assistant
The mod.rs is just a re-export file. The actual code must be in the submodules. Let me look at the surfaces module since it mentions
import_openapi_surface.Assistant
Now let me look at the import.rs to understand the
resolve_refmethod and how refs are resolved for schemas/parameters.Assistant
Now let me look at the existing tests to understand the test patterns.
Assistant
Now I understand the existing tests. Let me look at the projection_tests.rs to understand the projection patterns.
Assistant
Let me look at the test_support.rs and document.rs.
Assistant
Now I have a clear understanding. Let me reproduce the issue first with a temporary test.
Assistant
Now let me make the edits. First, update the call site in
import_response:Assistant
The replace command uses a different syntax. Let me re-read the usage. It says:
replace << 'EOF' >>> SEARCH def greet(user: str): click.echo(f"Hi {user}!") >>> REPLACE def greet(user: str): click.echo(f"Hello {user}!") EOFSo the heredoc uses SEARCH and REPLACE markers inside it. Let me try that.
Assistant
Now update the
resolve_refcall to use&schemasinceschemais now owned:Assistant
Now let me convert the
select_json_responsefree function into a method that resolves$refs:Assistant
I need to move the
select_json_responsemethod inside theimplblock. The closing}at line 100 closes the impl block prematurely. Let me fix this:Assistant
Now let me build to check for compilation errors:
Assistant
It compiles. Now let me add a regression test. Let me add it to the openapi_tests.rs file:
Assistant
Now let me add a regression test at the end of the openapi_tests.rs file:
Assistant
I see a duplicate assert line at 322-323. Let me fix that:
Assistant
Now let me run the tests:
Assistant
All 207 tests pass, including my new tests. Let me verify my new tests specifically run:
Assistant
All tests pass including my 3 new tests. Let me verify the fix actually addresses the issue by confirming the behavior would have failed before the fix. Let me temporarily revert just the responses.rs change to confirm the test would fail:
Assistant
The stash reverted both files. Let me do a more targeted test: revert only the responses.rs source change while keeping the test:
Assistant
The test fails without the fix (confirming the bug). Now let me restore the fixed version:
Assistant
Now let me run clippy to make sure there are no lint issues, and run the full test suite once more:
Assistant
All 207 tests pass and clippy is clean. Let me review the final diff:
Assistant
The diff looks clean. Let me view the test additions too:
Assistant
Let me verify the full workspace builds since other crates might depend on coral-spec:
Assistant
The full workspace builds. Let me run a broader test to make sure nothing else broke across the workspace that depends on coral-spec:
Assistant
There are two failures in
source_lifecycle_tests. Let me check whether these are pre-existing failures unrelated to my changes:Assistant
These two failures look environment-dependent (testing config write/cleanup failures that likely rely on filesystem permission denial — and we're running as root). Let me verify they're pre-existing by stashing my changes:
Assistant
The output got swallowed. Let me re-run on a clean tree explicitly:
Assistant
Confirmed —
import_rolls_back_on_config_write_failurefails on the clean tree too. These two failures are pre-existing and environment-dependent (running as root means the filesystem write-failure injection can't be triggered), completely unrelated to my changes.Let me clean up the temp file and do a final review:
Assistant
All v4 tests pass. Let me do a final review of the complete responses.rs to ensure correctness:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.