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 false-as-map behavior with the nearest existing test setup, patch the importer, and run focused and broader relevant tests. - Assistant
ripgrepis unavailable, so I’ll usegrepandfindto locate the Rust importer implementation and tests. - Assistant
The likely bug is at
crates/coral-spec/src/v4/surfaces/openapi/schemas.rs, where any present value enters the map branch. I’ll read crate-specific guidance, the full importer, related type definitions, and existing v4 OpenAPI tests before changing behavior. - Assistant
The code confirms the defect:
falseis recursively imported as an untyped object (defaulting toJson), then wrapped inMap. Existing properties take precedence, while schema-valuedadditionalPropertiesalready creates maps. I’ll inspect test conventions and IR serialization to determine the exact expected closed-object shape and whethertrueshould remain free-form. - Assistant
The IR represents a closed object as
IrTypeShape::Object { fields }, including an empty field list. The correct branching is therefore:false→ empty object, schema object → typed map,true→ free-form JSON-valued map, absent → existing generic JSON fallback. Before patching, I’ll use a temporary crate example (removed afterward) to exercise the public import API and print the current shapes for false, true, and schema-valued cases. - Assistant
The reproduction shows the reported failure exactly:
closedis aMapwith a generated JSON value type, while typed maps correctly point to a string scalar. I’ll make the smallest semantic change—special-case booleanfalsebefore the existing map branch—so schema-valued and boolean-truebehavior remain unchanged. - Assistant
The same reproduction now yields an empty
Objectforfalse, whiletrueremains a JSON-valuedMapand schema-valued additional properties remain a typedMap. I’ll remove the temporary example, format the code, run allcoral-spectests, and inspect the diff. - Assistant
All 219 unit tests and the crate doctest pass, formatting is clean, and only the importer source remains modified. I’ll run the crate’s all-target Clippy check as the final static validation, then review repository status for any generated or temporary artifacts.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.