-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Description
Hey! I've been testing the new codegen feature (great work on this, btw!) and ran into an internal error when using allOf with multiple schemas to create intersection types.
Environment
- CLI Version: 14.1.0
- OS: macOS 15.5
- Build: From source using
make - Target: TypeScript
Minimal Reproduction Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"allOf": [
{
"properties": {
"name": { "type": "string" }
}
},
{
"properties": {
"age": { "type": "integer" }
}
}
]
}
Command
jsonschema codegen schema.json --target typescript --name Person
Expected Behavior
Should generate a TypeScript interface combining both schemas:
{
"error": "Rule condition holds after application: unnecessary_allof_wrapper"
}The unnecessary_allof_wrapper optimization rule appears to be triggering incorrectly when allOf contains multiple schemas. The rule is designed to unwrap single-element allOf wrappers (e.g., { "allOf": [X] } → X), but the post-condition check seems to fail when processing actual intersection types.
Offer to Help
I'd be happy to work on a PR for this if you can point me in the right direction! I've already built the project locally and have test cases ready. Let me know if there's a specific approach you'd prefer for handling allOf intersections in the TypeScript codegen.