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
I’ll first inspect the repository structure and search for the v4 OpenAPI schema importer and its handling of
additionalProperties. Then I’ll reproduce the incorrect branch behavior, make the narrow importer fix, and run focused plus relevant broader tests. - Assistant
rgis unavailable, so I’ll usefind/grep. Before editing, I’ll read the repository guidance and identify Rust files containing the relevant importer logic and tests. - Assistant
The likely defect is the
else if let Some(additional)presence check inschemas.rs. I’ll inspect that file in full, its surrounding module APIs, data model semantics, and nearby test conventions so the fix preserves schema-valued maps while representing closed objects correctly. - Assistant
The defect reproduces directly from the control flow: an object with no named properties and
"additionalProperties": falseenters the map branch; recursively importing the boolean creates a JSON-valued type, so the parent becomesMap. The correct narrow distinction is:falsemeansObject { fields: [] }, while an object/schema value (and likely booleantrue) remains map-like. I’ll inspect importer entry points and existing OpenAPI assertions to confirm IDs and expected IR, then patch only production code because the environment rules explicitly prohibit changing or adding tests. - Assistant
Existing tests expose the public import function and inspect
IrTypeShape, so I can reproduce and verify through a temporary example or temporary unit test that is removed before submission. First I’ll inspect shape serialization and search existing tests for map behavior, including the remainder ofopenapi_tests.rs, to avoid changing intendedtrueor schema-valued behavior. - Assistant
No existing test covers maps. I’ll now make a standalone temporary Cargo program outside the repository that imports
coral-specby path and prints the imported output type shapes for three schemas:additionalProperties: false,true, and{type: string}. This provides an actual before/after reproduction without adding or modifying repository tests. - Assistant
The temporary program compiled the crate but used the wrong export path;
import_openapi_surfaceis re-exported from the publicv4module rather than the crate root. I’ll correct only that temporary program and rerun the reproduction. - Assistant
The reproduction confirms all three currently become maps, including the closed schema. I’ll add an explicit boolean-false branch before the existing generic
additionalPropertiesbranch. This is intentionally narrow: empty closed objects becomeObjectwith no fields;true, schema objects, references, and even previously tolerated malformed values retain the existing map import path. Objects with namedpropertiesalready remain objects and require no change. - Assistant
The patch is formatted and clean. I’ll rerun the same external reproduction and extend its output to include all generated types, verifying both that
falsenow yields an empty object and that schema-valued additional properties still create a map whose value type is a string scalar. Then I’ll run the crate’s full test suite. - Assistant
The post-fix reproduction now shows the exact intended distinctions: closed object for
false, JSON map fortrue, and string-valued map for a schema. All 219coral-specunit tests and its doctest pass. Since the repository guidance requiresmake rust-checksfor Rust changes, I’ll inspect that target and then run it; afterward I’ll review status/diff for unintended generated or lockfile changes. - Assistant
make rust-checkscompleted formatting and workspace Clippy with-D warnings, but stopped because the environment lacks thecargo-nextestexecutable—not because of a code failure. Rather than alter dependencies or install tooling, I’ll use standard Cargo as the closest available replacement for the workspace test command, with the same workspace/all-targets/all-features/locked scope, then run the documentation command separately. - Assistant
The standard full workspace suite compiled and ran broadly, but two unrelated filesystem-permission integration tests failed because they expect writes/deletes to fail under permission changes; this environment runs as root, so those operations succeed. The relevant crate suite already passed, and all other shown workspace tests passed up to that point. Because
&&prevented docs from running after those environmental failures, I’ll run docs now, then inspect the repository status and final diff to ensure only the intended source file changed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.