Skip to content

Commit

Permalink
support for additionalItems
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-ai committed Dec 11, 2024
1 parent a7b69d6 commit de3cbc4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions parser/src/json/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DEFAULT_DRAFT: Draft = Draft::Draft202012;
const TYPES: [&str; 6] = ["null", "boolean", "number", "string", "array", "object"];

// Keywords that are implemented in this module
const IMPLEMENTED: [&str; 22] = [
const IMPLEMENTED: [&str; 23] = [
// Core
"anyOf",
"oneOf",
Expand All @@ -26,6 +26,7 @@ const IMPLEMENTED: [&str; 22] = [
"type",
// Array
"items",
"additionalItems",
"prefixItems",
"minItems",
"maxItems",
Expand Down Expand Up @@ -610,7 +611,14 @@ fn compile_type(ctx: &Context, tp: &str, schema: &HashMap<&str, &Value>) -> Resu
get("minItems"),
get("maxItems"),
get("prefixItems"),
get("items"),
match (get("items"), get("additionalItems")) {
(Some(items), None) => Some(items),
(None, Some(additional_items)) => Some(additional_items),
(Some(_), Some(_)) => {
bail!("Cannot specify both 'items' and 'additionalItems'")
}
_ => None,
},
),
"object" => compile_object(
ctx,
Expand Down

0 comments on commit de3cbc4

Please sign in to comment.