Skip to content

Commit 0c5677c

Browse files
committed
[Bugfix] Fix complex intersections of allOf/anyOf/properties/required (fix #381)
1 parent 6adcad9 commit 0c5677c

File tree

5 files changed

+33952
-503
lines changed

5 files changed

+33952
-503
lines changed

src/parser.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,20 @@ via the \`patternProperty\` "${key.replace('*/', '*\\/')}".`
427427
)
428428
}
429429

430+
if (schema.required) {
431+
asts = asts.concat(
432+
map(schema.required, key => {
433+
return {
434+
ast: {type: 'UNKNOWN'},
435+
isPatternProperty: false,
436+
isRequired: true,
437+
isUnreachableDefinition: false,
438+
keyName: key,
439+
}
440+
}),
441+
)
442+
}
443+
430444
if (options.unreachableDefinitions) {
431445
asts = asts.concat(
432446
map(schema.$defs, (value, key: string) => {

src/typesOfSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ const matchers: Record<SchemaType, (schema: JSONSchema) => boolean> = {
140140
}
141141
return 'enum' in schema
142142
},
143-
UNNAMED_SCHEMA() {
144-
return false // Explicitly handled as the default case
143+
UNNAMED_SCHEMA(schema) {
144+
return !('$id' in schema) && ('patternProperties' in schema || 'properties' in schema || 'required' in schema)
145145
},
146146
UNTYPED_ARRAY(schema) {
147147
return schema.type === 'array' && !('items' in schema)

0 commit comments

Comments
 (0)