Skip to content

Commit 7632038

Browse files
kevinccbsgclaude
andcommitted
fix: handle nullable without type in OpenAPI 3.0 normalization
Schemas using `nullable: true` without a `type` field (e.g. allOf compositions) were not being normalized, causing Ajv to throw "nullable cannot be used without type". Wrap these in anyOf with a null branch, matching the existing pattern for oneOf/anyOf/type cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c0b25ed commit 7632038

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/normalize.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ function normalizeSchema(schema: Schema): Schema {
3434
delete result.nullable;
3535
return normalizeChildren(result);
3636
}
37+
// nullable without type (e.g. allOf composition or bare description):
38+
// wrap in anyOf with null branch
39+
if (schema.type === undefined) {
40+
const rest: Schema = { ...schema };
41+
delete rest.nullable;
42+
return normalizeChildren({ anyOf: [rest, { type: 'null' }] });
43+
}
3744
}
3845

3946
// Handle exclusiveMinimum boolean (3.0 style)

0 commit comments

Comments
 (0)