ISSUE DESCRIPTION Respect additionalProperties false during v4 OpenAPI schema import…
- User
ISSUE DESCRIPTION
Respect additionalProperties false during v4 OpenAPI schema import This tracks unresolved feedback identified by cubic on PR #1149: https://github.com/withcoral/coral/pull/1149#discussion_r3347190658
Context: This appears to be pre-existing DSL v4 behavior surfaced by the refactor review, not a regression from the module split.
Problem: The schema importer treats the presence of
additionalPropertiesas map-like, soadditionalProperties: falsecan be imported as a free-form map instead of a closed object.Acceptance criteria: Handle boolean
additionalProperties: falseas a closed object, preserve schema-valued additionalProperties behavior, and add focused schema import coverage.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.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
- Assistant
I'll start by exploring the repository structure and locating the OpenAPI schema import code related to
additionalProperties. - Assistant
The OpenAPI import lives under
coral-spec. Next I'll inspect schema import and any tests mentioningadditionalProperties. - Assistant
rg is not available, let me use grep instead.
- Assistant
The main file is
./crates/coral-spec/src/v4/surfaces/openapi/schemas.rs. Let me read that file carefully. - Assistant
Let me read the rest of the file, particularly the additionalProperties handling.
- Assistant
I've found the bug path. Next I'll inspect IR type shapes and existing OpenAPI import tests for coverage patterns.
- Assistant
Let me look at the openapi tests structure and existing schema tests more carefully. Also check the PR discussion reference and AGENTS.md for test conventions.
- Assistant
Let me look at a recent similar test for patterns, and also the recursive schema test since it was recently strengthened.
- Assistant
I'll check whether
"json"is a built-in type and review recent similar commits for the expected pattern. - Assistant
I'll implement the fix for boolean
additionalProperties: falseand add focused import tests. - Assistant
The edit landed in the wrong file. I'll restore the test file and apply the change to
schemas.rs. - Assistant
Good, tests are restored and schemas.rs is open. Let me apply the fix properly.
- Assistant
Next I'll add focused import coverage at the end of
openapi_tests.rs. - Assistant
I'll add a comprehensive test covering:
- Assistant
I'll append a focused test covering the additionalProperties cases.
- Assistant
I need to check type_id_from_ref - does "Closed" become "closed"?
- Assistant
Need to search recursively with the right flags.
- Assistant
Yes, Closed becomes closed, TypedMap becomes typed_map, ClosedWithFields becomes closed_with_fields. Good.
Also for freeform with additionalProperties: true - before my change it would import
trueas schema and get a type like freeform_value with Json shape, then Map with that value_type_ref. Now it uses "json" directly. Does "json" need to exist as a type in the types map?Looking at other places that use "json".to_string() for type_ref - they seem fine with magic type refs. Let me check if projections or anything require types to contain "json".
- Assistant
Map becomes Json at projection level regardless of value_type_ref, so "json" is fine. Running the focused tests next.
- Assistant
The type id
closedisn't present. I'll dump the imported type ids to see what names were produced. - Assistant
Refs resolve to
closed_get_rowrather than component names—I'll inspect how$refresolution works. - Assistant
Looking at type ids:
closed_get_row- so $ref didn't work to get type id from ref forcomponent schema... Actually in import_schema:let type_id = schema.get("$ref").and_then(Value::as_str).map_or_else( || normalize_identifier(suggested_id, "type"), type_id_from_ref, );If schema has ref wasn't passed, or resolve_ref واiled and something else happened...
- Assistant
They resolve the ref first, stripping
$refbefore import—I'll checkclassify_response_schemanext. - Assistant
So resolve_ref resolves the schema before classify, so $ref is gone when importing. The tree test conceptual - after resolve_ref, the tree schema comes from components, and then import_schema gets suggested_id let's see...
Looking at tree test again from the git commit - it expected type_ref "tree". Let me re-read that test file carefully.
- Assistant
Interesting—the recursive tree test still expects type_ref
"tree". I'll re-read the fullresolve_refpath. - Assistant
I'll print the tree operation's type_ref to reconcile that with the
closed_get_rownaming. - Assistant
I'll dig into select_json_response more carefully—maybe the schema is passed differently.
- Assistant
I'll temporarily instrument
import_schemato log how the tree type id is chosen. - Assistant
I'll instrument
import_responseto log the schema before and after resolve. - Assistant
There's a clippy warning potentially about format in eprintln but let me run the test.
- Assistant
Wrapped-list classification explains the tree
$ref. I'll point the test at operationtype_refids instead, and strip the debug logging. - Assistant
Good, cleaned up debug. Now add the proper test. Also verify schemas.rs still has our fix.
- Assistant
Wait - for closed_with_fields, it has a type object under properties including id: string. The wrapped_list path shouldn't match since there's no array. Running the test next.
- Assistant
The new test passed. Next I'll run the full coral-spec OpenAPI suite to check for regressions.
- Assistant
All OpenAPI tests passed. Running the full coral-spec suite next.
- Assistant
All 220 tests passed. Running clippy on the changed package to match the repo checks.
- Assistant
Clippy flagged the new test for length and indexing. I'll trim it and avoid direct index access.
- Assistant
Interesting—indexing is denied even in tests. I'll check how other tests access fields.
- Assistant
Looking at projection_tests for how they handle too_many_lines:
- Assistant
I'll tighten the test and resolve the clippy findings.
- Assistant
Re-running clippy and tests next.
- Assistant
Clippy is clean. Verifying the final diff, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.