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 to understand what we're working with.
Assistant
I'll start by exploring the repository structure.
Assistant
Now let me look at the
IrTypeShapedefinition to understand the available shapes.Assistant
Now let me look at the
resolve_reffunction and the import module structure.Assistant
Let me look at the existing tests for the schema import to understand the test structure.
Assistant
Let me see the rest of the test file and check how tests are organized.
Assistant
Now I understand the test structure. Let me reproduce the issue first. The problem is in the
import_schemafunction. WhenadditionalProperties: falseis present, the code treats it as a map. Let me write a quick reproduction test.Assistant
Now let me write a test to reproduce the issue. Let me add a temporary test to the openapi_tests.rs file.
Assistant
Now let me write a reproduction test to confirm the bug. I'll add a temporary test in the openapi_tests.rs file.
Assistant
The heredoc stripped indentation. Let me fix the test indentation.
Assistant
The issue is the
.as_bytes()line lost its indentation. Let me check line 703.Assistant
The issue is that the raw string
r"is at column 0 (not indented) which is fine for raw strings, but the.as_bytes()is indented with 8 spaces which is fine too. Wait, the error says line 703 expected expression. Let me look at the raw string more carefully. Ther"starts the raw string. The issue might be that the raw string starts with a newline and the closing"is at indentation level. Let me look at how other tests format it.Looking at the existing tests, they use:
coder" openapi: 3.0.3 ... " .as_bytes(),So the
r"is at 8 spaces indentation, the content starts on the next line at column 0, and the closing"is at column 0, then.as_bytes()is at 8 spaces.But in my appended test, the content was dedented by the heredoc. Let me look at the actual content. The
r"line - let me check.Assistant
The format looks correct. Let me compare with an existing working test more carefully.
Assistant
The format looks identical. Let me look at exactly what the compiler complains about by checking the line numbers.
Assistant
Let me re-run the compile to see the current error.
Assistant
Let me check for hidden characters in the raw string area.
Assistant
Let me check if there are any double quotes in the raw string content.
Assistant
Let me remove the appended test and re-add it properly using the edit tool.
Assistant
Now let me open the file and add the test using the edit tool with proper formatting.
Assistant
Now I'll add my reproduction test using the edit tool to ensure proper formatting.
Assistant
Interesting - in this case the shape is
Objectbecause properties exist. The bug manifests when there are no properties butadditionalProperties: false. Let me test that case.Assistant
I've confirmed the bug. When
additionalProperties: falseis present with no properties, it's imported as aMapinstead of a closed object. Let me remove the temp test and implement the fix.Assistant
Now let me look at the exact code to fix.
Assistant
Now I understand the bug. Let me implement the fix in the
additionalPropertiesbranch.Assistant
The fix looks good. Now let me verify it compiles and then write a proper test to verify the behavior.
Assistant
Now let me add a focused test for the schema import coverage. Let me look at the test file structure to match conventions.
Assistant
Now let me add a focused test at the end of the file for the
additionalPropertiesbehavior.Assistant
The test was added correctly. Let me run it to verify.
Assistant
The same error appears. Let me check for any double quotes in the raw string content.
Assistant
Let me check the exact bytes around the raw string boundaries.
Assistant
I see the issue! The closing
"has a comma on the same line (",), but it should be just"with.as_bytes(),on the next line (method call on the string). Let me fix this.Assistant
Now let me run the test.
Assistant
The test passes. Now let me run the full test suite for the coral-spec crate to make sure I didn't break anything.
Assistant
All 220 tests pass. Let me also check clippy and look for any other places that might need similar handling.
Assistant
No clippy warnings. Let me also check if there are other places in the codebase that reference
additionalPropertiesfor schema import that might need the same fix.Assistant
The only schema import handling is in
schemas.rswhich I've fixed. Thecoral-mcpreferences are for output generation. Let me verify that quickly and also run the broader test suite to be safe.Assistant
Those are output schema generation, not import. Now let me run the broader workspace test to ensure nothing else is affected.
Assistant
Let me also check the coral-app materialization reference and run its tests.
Assistant
That file matched
import_openapi_surface, notadditionalProperties. Let me review the final state of my changes.Assistant
The changes look clean. Let me run rustfmt to ensure formatting compliance and then run the full test suite one final time.
Assistant
Let me apply the formatting fixes.
Assistant
Formatting is now clean. Let me run the full test suite one final time to confirm everything passes.
Assistant
Let me run clippy one more time on the formatted code to be thorough.
Assistant
Let me check the project's clippy configuration to see if this warning level is enforced.
Assistant
Let me check if CI enforces clippy with deny-warnings, and how existing tests handle long functions.
Assistant
CI enforces clippy with
-D warnings. My test triggerstoo_many_lines. Let me check the existing test function line counts and the lint threshold.Assistant
The codebase convention is to use
#[expect(clippy::too_many_lines, reason = "...")]on long test functions. Let me add that to my test.Assistant
Now let me run clippy with the CI-equivalent flags and the test suite one final time.
Assistant
Clippy passes with
-D warnings. Let me run the tests and fmt check one final time.Assistant
Everything passes. Let me do a final review of the complete diff.
Assistant
The changes are complete and correct. Let me run the complete v4 test module one final time to confirm everything is green.
Assistant
All tests pass. Let me provide my final summary and checklist review.
Summary of Changes
Problem
The v4 OpenAPI schema importer in
crates/coral-spec/src/v4/surfaces/openapi/schemas.rstreated the mere presence ofadditionalPropertiesas map-like. SoadditionalProperties: false(which means "closed object, no extra properties allowed") was being imported as a free-formMapinstead of a closed object.Assistant
The changes are ready to submit. Both modified files contain the fix and the focused test coverage.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.