diff --git a/common/json-schema-to-grammar.cpp b/common/json-schema-to-grammar.cpp index 9c67050a67..322f91b6e0 100644 --- a/common/json-schema-to-grammar.cpp +++ b/common/json-schema-to-grammar.cpp @@ -828,7 +828,6 @@ public: return _add_primitive(rule_name == "root" ? "root" : type, PRIMITIVE_RULES.at(type)); } - // An allOf merges its components: the properties of a direct component are required, those of a nested anyOf are optional, enums are intersected. std::string _visit_all_of(const common_schema_all_of & schema, const std::string & name, const std::string & rule_name) { std::unordered_set required; std::vector> properties; diff --git a/common/json-schema.h b/common/json-schema.h index 194c12f073..60db8afd0e 100644 --- a/common/json-schema.h +++ b/common/json-schema.h @@ -9,8 +9,7 @@ #include #include -// JSON schema IR, covering the subset that json_schema_to_grammar() can convert. -// A $ref becomes a common_schema_ref whose target is owned by the common_schema_document, so a recursive schema stays finite. +// JSON schema, covering the subset that json_schema_to_grammar() can convert. struct common_schema { enum node_kind { @@ -30,7 +29,6 @@ struct common_schema { KIND_OBJECT, }; - // The JSON types a value may have, as named by the "type" keyword enum value_type { TYPE_NULL, TYPE_BOOLEAN, @@ -80,23 +78,17 @@ struct common_schema { virtual ~common_schema() = default; virtual node_kind kind() const = 0; - // The types of value matching the schema: the union over anyOf, the intersection over allOf, every type for an any. - // A number schema accepts integers too, so it has both. type_set value_types() const; // Whether a value matching the schema may be a string, through any branch of it. - // Unlike value_types() an any does not count: some models emit raw string values rather than - // JSON-encoded strings for string parameters, and an unconstrained parameter is parsed as JSON. bool may_be_string() const; - // e.g. "anyOf" / "string", for messages static const char * kind_name(node_kind kind); static const char * type_name(value_type type); }; using common_schema_ptr = std::unique_ptr; -// {} or a schema with no recognized keywords: any JSON value struct common_schema_any : common_schema { node_kind kind() const override { return KIND_ANY; } }; @@ -175,7 +167,6 @@ struct common_schema_array : common_schema { node_kind kind() const override { return KIND_ARRAY; } }; -// "prefixItems", or "items" given as an array: one schema per position struct common_schema_tuple : common_schema { std::vector items; @@ -195,7 +186,6 @@ struct common_schema_object : common_schema { node_kind kind() const override { return KIND_OBJECT; } }; -// A parsed schema: its root, and the target of every $ref it reaches keyed by the $ref string struct common_schema_document { common_schema_ptr root; std::map refs; diff --git a/common/peg-parser.h b/common/peg-parser.h index 6924445f16..b80132eb33 100644 --- a/common/peg-parser.h +++ b/common/peg-parser.h @@ -243,7 +243,6 @@ struct common_peg_until_parser { std::vector delimiters; }; -// The schema is not saved: a loaded arena parses, only the arena that built it generates grammar struct common_peg_schema_parser { common_peg_parser_id child; std::string name;