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.
Assistant
Let me start by understanding the repository structure and the issue at hand.
The issue is about respecting
additionalProperties: falseduring OpenAPI schema import (v4). The problem is that the schema importer treats the presence ofadditionalPropertiesas map-like, soadditionalProperties: falsecan be imported as a free-form map instead of a closed object.Let me explore the repository structure first.
Assistant
This is a Rust project. Let me find the relevant code related to OpenAPI schema import and `additionalProperties
Assistant
Let me look at the relevant files. Let's start with the main one
Assistant
Let me use
cator theopenspecial command with the full path. Actually, theopenspecial command should work. Let me try again.Assistant
Let me see the rest of the file to understand the full logic.
Assistant
Now I can see the issue. Let me look at lines 102-114. When
additionalPropertiesisfalse(a boolean), the code enters theelse if let Some(additional)branch and treats it as a map, which is incorrect. Let me also look at theresolve_reffunction and understand the IR typesAssistant
Let me look at the
resolve_reffunction to understand how it handles values.Assistant
Let me try using the bash terminal to open the file.
Assistant
Now I understand the issue clearly. Let me look for existing tests related to schema import.
Assistant
Let me find test files for OpenAPI schema import
Assistant
Let me look at the openapi_tests.rs file
Assistant
Now I have a clear understanding of the issue. Let me first create a reproduction script to confirm the problem, then fix it
Assistant
Good, all existing tests pass. Now let me create a reproduction script to confirm the bug.
Assistant
Now I understand the issue fully. Let me fix the code. The problem is on line 102 -
additionalProperties: falsematchesif let Some(additional)and incorrectly creates a Map type.Assistant
Let me use replace instead
Assistant
Let me try using sed to make the edit
Assistant
Let me verify the change
Assistant
The change looks correct. Let me build the project to check for compilation errors
Assistant
Build succeeds. Now let me run the existing
Assistant
All 219 tests pass. Now let me add a focused test for the
additionalProperties: falsebehavior as the acceptance criteria requests. Let me look at the test file to find a good place to add the test.Assistant
Let me see the end of the test file to add a test at the
Assistant
Let me add a test at the end of the test file
Assistant
Now let me run the tests to see if the new test passes
Assistant
The new test passes. Let me run all tests once more to confirm everything is green
Assistant
All 220 tests pass. Let me verify the diff of changes
Assistant
The changes look correct. Let me now go through the checklist:
Checklist Review
1. Successfully reproduced the error
The issue describes that
additionalProperties: falseis treated as map-like during schema import. I confirmed this by examining the code at line 102 ofschemas.rs: the conditionif let Some(additional) = resolved.get("additionalProperties")matches ANY value includingfalse, causing the code to enter the Map branch incorrectly.2. Confirmed the fix resolves the error
The fix uses
.is_some_and(|v| v.as_bool() != Some(false))to explicitly excludeadditionalProperties: falsefrom the map branch. The new test verifies:- Object with properties +
additionalProperties: false→IrTypeShape::Object✅ - Object without properties +
additionalProperties: false→ NOT a Map ✅ - Object with
additionalPropertiesas schema → (preserved) ✅
- Object with properties +
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.