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.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.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /coral, current file: none) bash-$
- Assistant
I'll start by exploring the repository to understand its structure and locate the relevant code for OpenAPI schema import. Let's first get an overview.
- Assistant
Let me explore the repository structure more broadly.
- Assistant
Let me search more broadly.
- Assistant
This is a Rust project with Cargo.toml. Let me look at the crates directory for relevant code.
- Assistant
Let me search for files related to OpenAPI schema import.
- Assistant
Let me explore the relevant files. First, let's look at the schemas.rs file since it seems most relevant.
- Assistant
Now I can see the issue! In the
import_schemamethod, there's a check foradditionalPropertiesthat treats any presence ofadditionalPropertiesas a map-like structure. However, whenadditionalProperties: falseis set in OpenAPI, it means the object should be closed (no additional properties allowed), not a free-form map. Let me look at the test files to understand the expected behavior better. - Assistant
Let me search for tests related to OpenAPI import.
- Assistant
Let me look at the openapi tests to understand the test structure.
- Assistant
Let me examine the IR types to understand
IrTypeShape::MapvsIrTypeShape::Object. - Assistant
Now let me look at the specific section of the import_schema method that handles
additionalProperties. I need to understand how it currently works. - Assistant
Let me see the rest of the file.
- Assistant
Now I understand the issue! The problem is in lines 102-114 where
additionalPropertiesis handled. WhenadditionalProperties: falseis present, the code tries to importfalseas a schema and creates a Map type, butadditionalProperties: falseshould be treated as a closed object (no additional properties allowed).Let me first create a test script to reproduce the issue and understand the current behavior:
- Assistant
Let me run the existing tests to see the current state:
- Assistant
Now let me implement the fix. I need to modify the handling of
additionalPropertiesin the schemas.rs file to handle booleanfalseas a closed object: - Assistant
Need to open the file first, then edit.
- Assistant
The file should exist since we saw its contents earlier. Let me try from the repository root.
- Assistant
Now let me scroll down to see lines 89-114 more clearly.
- Assistant
Now I need to replace lines 89-114 with the fixed version. The issue is that
additionalProperties: falseis treated as a map, but it should be treated as a closed object. Let me create the replacement. - Assistant
I see there's an extra
}on line 135. I need to remove the duplicate closing brace. - Assistant
There's still an extra
}on line 135. Let me remove it by replacing lines 134-136: - Assistant
Good! Now I need to simplify the logic when properties exist. The current code has redundant logic. Let me fix lines 90-110:
- Assistant
I see there's a syntax error. There's an extra
}on line 102 and theelsebranches are not properly connected. Let me fix this by replacing lines 89-126: - Assistant
Good! Now let me verify the code compiles:
- Assistant
Good! The code compiles. Now let me run the existing tests to make sure I didn't break anything:
- Assistant
The current working directory is already
/coral/crates/coral-spec. Let me run the test from the root. - Assistant
All existing tests pass. Now I need to add test coverage for the
additionalProperties: falsebehavior as requested in the acceptance criteria. Let me find and add to the openapi tests file: - Assistant
Let me first verify my understanding by creating a temporary test to see how the current behavior handles
additionalProperties: false: - Assistant
Now I need to add test coverage for the
additionalProperties: falsebehavior. Let me add a focused test to the openapi_tests.rs file: - Assistant
I need to add a test for the
additionalProperties: falsebehavior. Let me scroll to the end of the file to see where to add it: - Assistant
Now let me add a test for the
additionalProperties: falsebehavior: - Assistant
I see there's a duplicate line on line 666. Let me fix that:
- Assistant
There's still a duplicate
}on line 667. Let me fix that: - Assistant
Good! Now let me run the tests to make sure everything compiles and the new tests pass:
- Assistant
The test failed because I'm looking for
items/getbut the operation id is likely normalized. Let me check what the operation id becomes after normalization. Looking at the existing tests, they useoperationId: items/listbut the operation is stored asitemslist(without the slash). Let me check. - Assistant
Let me check how operation ids are stored:
- Assistant
Let me check how the operation id is set in the import code:
- Assistant
Let me check how the operation id is constructed in the import code:
- Assistant
Let me check what operation ids are actually generated by printing them out:
- Assistant
The operationId is being normalized (likely lowercased and special chars removed). Let me check by looking at how the existing tests use operationId:
- Assistant
Let me check how the test that uses
operationId: items/getaccesses the operation: - Assistant
Let me check how the normalize_identifier function works:
- Assistant
Let me look at how the operation id is set:
- Assistant
Let me look at how operation IDs are being created in the importer:
- Assistant
Let me check how the test for
trees/getaccesses the operation: - Assistant
I see the issue! The test expects
operationId: items/getto be normalized. Let me check how the normalize_identifier function works and see what the actual normalized ID is: - Assistant
I see. The
normalize_identifierfunction converts non-alphanumeric characters to underscores and lowercases everything. Soitems/getwould becomeitems_get. Let me fix my test to use the correct normalized IDs: - Assistant
I see there's duplicate code. Let me clean up the test:
- Assistant
Good! Now let me run the tests again:
- Assistant
Excellent! All tests pass. Now let me run the full test suite to make sure I didn't break anything:
- Assistant
All tests pass! Now let me also check if there are any other crates that might be affected by this change. Let me check the MCP tools file:
- Assistant
These are test fixtures in the MCP tools file that use
additionalProperties: false. They're not related to the OpenAPI importer - they're just test data. Let me verify by looking at a snippet: - Assistant
Let me look at the MCP tools file to understand the context:
- Assistant
These are MCP tool definitions, not related to the OpenAPI importer. Let me now run the full test suite for the entire repository to make sure I haven't broken anything else:
- Assistant
The two failing tests are in the
coral-appcrate and are about config write failures and cleanup failures - they seem unrelated to my changes. Let me check if these tests were already failing before my changes: - Assistant
Let me check if these tests were already failing before my changes:
- Assistant
Now let me run the failing tests without my changes:
- Assistant
Good, these tests were already failing before my changes. Let me restore my changes:
- Assistant
Good, the failing tests are pre-existing and not related to my changes. Now let me verify my changes are correct by looking at the diff:
- Assistant
Perfect! The diff shows that my changes are minimal and focused. I added a new
else ifbranch that checks ifadditionalPropertiesisfalseand returns an empty Object in that case. This correctly handles the case whereadditionalProperties: falseis used without properties.Now let me check the diff for the test file:
- Assistant
Perfect! The test diff looks good. I've added two new tests:
importer_respects_additional_properties_false_as_closed_object- Tests thatadditionalProperties: falseis handled correctly as a closed objectimporter_preserves_schema_valued_additional_properties_as_map- Tests that schema-valuedadditionalPropertiesis still handled as a Map
Now let me run the openapi tests one more time to make sure everything passes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →