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.
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.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- Assistant
I'll start by exploring the repository structure to understand the codebase and locate the relevant files. Let's first look at the directory.
- Assistant
Let me explore the repository structure and understand the codebase. The issue is about resolving OpenAPI
$refresponse objects during DSL v4 import. Let me look at the relevant files. - Assistant
Let me look at the specific file mentioned in the issue:
crates/coral-spec/src/v4/mod.rsat lines 972 and 1290. - Assistant
Let me look at the relevant lines in the
mod.rsfile mentioned in the issue. The issue mentions:crates/coral-spec/src/v4/mod.rs:972crates/coral-spec/src/v4/mod.rs:1290
Let me check those lines.
- Assistant
The file only has 54 lines - the line numbers in the issue may refer to the older version. Let me look at the actual relevant files - responses.rs seems most likely.
- Assistant
Now I understand the issue. The
select_json_responsefunction iterates over responses and directly looks forcontentproperty, but when a response is a$ref(like$ref: '#/components/responses/Foo'), it doesn't havecontentdirectly - it needs to be resolved first. Let me look at the import.rs file to understand how$refs are resolved elsewhere. - Assistant
Now I understand the issue. In
select_json_response, when a response object is a$ref(like$ref: '#/components/responses/Foo'), the function tries to getcontentdirectly from the response object without first resolving the$ref. Thecontentis on the resolved object, not the$refwrapper.Let me look at the operations.rs to understand how the import flow works:
- Assistant
Now I understand the issue clearly. The
select_json_responsefunction iterates over response objects and directly checks forcontent, but doesn't resolve$refreferences first. When a response is{ "$ref": "#/components/responses/Foo" }, it has nocontentkey, so it gets skipped.Let me look at the existing tests to understand the test patterns:
- Assistant
Now I have a clear understanding. The problem is in
select_json_response- it iterates over each response object and looks forcontentdirectly, but when a response is a$ref, thecontentis only on the resolved object. Let me implement the fix. - Assistant
Now I understand the problem. The
select_json_responsefunction looks forcontentdirectly on each response object, but when a response is expressed as a$ref, thecontentis on the resolved object, not the ref wrapper. Let me implement the fix.The approach: In
import_response, resolve any response-level$refs before passing them toselect_json_response. This is consistent with how parameters and request bodies already resolve refs. - Assistant
Good, the import_response function now resolves response
$refs before passing toselect_json_response. But I need to verify theselect_json_responsefunction signature. Let me check the current state of the file. - Assistant
Good. The
select_json_responsefunction signature is alreadyOption<&Map<String, Value>>which matches what we're passing withresolved_responses.as_ref(). Now let me run the existing tests to make sure nothing is broken: - Assistant
There's a double closing brace. Let me fix it:
- Assistant
There's an extra closing brace on line 123. Let me remove it:
- Assistant
There's a duplicate function declaration now. Let me fix this by removing the extra one:
- Assistant
The file is getting messy with duplicates. Let me rewrite it cleanly from scratch by first checking what the original file looked like and then recreating it properly.
- Assistant
I need to remove the duplicate function declaration. Let me fix it properly:
- Assistant
Good, the file looks clean now. Let me verify there's proper spacing and try to compile:
- Assistant
Great, it compiles. Now let me run the existing tests:
- Assistant
All existing tests pass. Now I need to add a regression test that covers a
200response that references#/components/responses/...and verifies the projection is published. Let me look at the existing test patterns and add a new test: - Assistant
Now let me add the regression test at the end of the file:
- Assistant
Wait, I see the previous test is missing its closing brace. Let me check:
- Assistant
I see the previous test function
importer_warns_for_invalid_parameters_and_unresolved_responsesis missing its closing brace. Let me fix this: - Assistant
There's a duplicate
#[test]attribute. Let me fix that: - Assistant
I see a duplicate function declaration on line 327. Let me fix:
- Assistant
I still have a duplicate line. Let me fix:
- Assistant
The file is getting messy with incremental edits. Let me just rewrite the last test cleanly from line 325 onwards:
- Assistant
Now let me run the tests to verify the new test passes:
- Assistant
All tests pass, including the new one. Let me run the full test suite to make sure nothing else is broken:
- Assistant
All 205 tests pass, including the new regression test. Let me verify my changes are correct by reviewing the final state of the modified files:
- Assistant
Let me look at the full diff:
- Assistant
I notice a minor formatting issue - the blank line between the impl block and
select_json_responsewas removed. Let me add it back: - Assistant
I notice line 122-123 have the closing brace of the impl block directly followed by the function declaration without a blank line. Let me fix this minor formatting issue.
- Assistant
Let me fix the syntax.
- Assistant
I see the issue - the blank line is still not showing. Let me use the replace command:
- Assistant
Good, now there's a blank line between the impl block and the free function. Let me run the tests one final time to confirm everything works:
- Assistant
All 205 tests pass. Let me also run the full workspace tests to make sure nothing else is broken:
- Assistant
The 2 failing tests are in
coral-appand are related to gRPC source lifecycle operations (import_rollback and delete_cleanup_failure). These are not related to my changes. Let me verify they fail on the original code too: - Assistant
Good, these are pre-existing failures unrelated to my changes. Let me restore my changes:
- Assistant
Let me do a final review of the changes:
- Assistant
The diff looks clean. Let me run the tests one more time to confirm everything is working:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.