Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions typify-impl/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,12 @@ impl TypeSpace {
extensions: _,
} => self.convert_unknown_enum(type_name, original_schema, metadata, enum_values),

// Subschemas
// Subschemas with no additional validation and either no type or a
// single type. A multi-type (`Vec`) instance_type is deliberately
// excluded so that it flows through the merge arm below.
SchemaObject {
metadata,
// TODO we probably shouldn't ignore this...
instance_type: _,
instance_type: None | Some(SingleOrVec::Single(_)),
format: None,
enum_values: None,
const_value: None,
Expand Down
68 changes: 68 additions & 0 deletions typify/tests/schemas/type-array-with-subschemas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$comment": "Coverage for issue #954: multi-type `type: [...]` alongside oneOf/anyOf/allOf/not.",
"definitions": {
"TypeArrayOneOfItems": {
"type": [ "string", "number", "boolean", "array" ],
"oneOf": [
{ "items": { "type": "string" } },
{ "items": { "type": "number" } },
{ "items": { "type": "boolean" } }
]
},
"TypeArrayAnyOfItems": {
"type": [ "string", "number", "array" ],
"anyOf": [
{ "items": { "type": "string" } },
{ "items": { "type": "number" } }
]
},
"TypeArrayAllOfRefinement": {
"type": [ "string", "array" ],
"allOf": [
{ "items": { "type": "string" } },
{ "minItems": 1 }
]
},
"TypeArrayNotExclusion": {
"type": [ "string", "number", "array" ],
"not": { "type": "object" }
},
"TypeArrayOneOfExplicitArrayBranches": {
"$comment": "Each oneOf branch pins `type: array`; the non-array variants from the outer union should be pruned.",
"type": [ "string", "array" ],
"oneOf": [
{ "type": "array", "items": { "type": "string" } },
{ "type": "array", "items": { "type": "number" } }
]
},
"TypeArrayPartiallyUnsatisfiableOneOf": {
"$comment": "Two oneOf branches conflict with the outer type union and should be dropped during merge.",
"type": [ "string", "array" ],
"oneOf": [
{ "type": "object", "properties": { "name": { "type": "string" } } },
{ "items": { "type": "string" } },
{ "type": "number" }
]
},
"TypeArrayFullyUnsatisfiableOneOf": {
"$comment": "Every branch conflicts with the outer type union; must resolve cleanly rather than panic.",
"type": [ "string", "number" ],
"oneOf": [
{ "type": "array", "items": { "type": "string" } },
{ "type": "object", "properties": { "k": { "type": "string" } } }
]
},
"TypeArrayOneOfAndAllOf": {
"$comment": "oneOf and allOf on the same object, plus a multi-type `type` array.",
"type": [ "string", "array" ],
"allOf": [
{ "minLength": 1 }
],
"oneOf": [
{ "items": { "type": "string" } },
{ "items": { "type": "number" } }
]
}
}
}
Loading