#include <json-schema-to-grammar.hpp>
Definition at line 456 of file json-schema-to-grammar.hpp.
◆ SchemaConverter()
| lloyal::detail::SchemaConverter::SchemaConverter |
( |
const std::function< json(const std::string &)> & |
fetch_json, |
|
|
bool |
dotall |
|
) |
| |
|
inline |
◆ _generate_constant_rule()
| std::string lloyal::detail::SchemaConverter::_generate_constant_rule |
( |
const json & |
value | ) |
|
|
inline |
◆ check_errors()
| void lloyal::detail::SchemaConverter::check_errors |
( |
| ) |
|
|
inline |
◆ format_grammar()
| std::string lloyal::detail::SchemaConverter::format_grammar |
( |
| ) |
|
|
inline |
◆ resolve_refs()
| void lloyal::detail::SchemaConverter::resolve_refs |
( |
json & |
schema, |
|
|
const std::string & |
url |
|
) |
| |
|
inline |
Resolve $ref pointers in JSON schema.
Recursively resolves all $ref fields in schema, fetching remote schemas as needed. Replaces relative refs (#/definitions/...) with absolute URLs and populates internal _refs map with resolved schema objects.
- Parameters
-
| schema | Schema object to resolve (modified in place) |
| url | Base URL for resolving relative references |
- Note
- Handles both absolute (https://...) and relative (#/definitions/...) refs
-
Errors accumulated in _errors vector for batch reporting
Definition at line 964 of file json-schema-to-grammar.hpp.
◆ visit()
| std::string lloyal::detail::SchemaConverter::visit |
( |
const json & |
schema, |
|
|
const std::string & |
name |
|
) |
| |
|
inline |
Convert schema node to GBNF rule.
Main entry point for schema-to-grammar conversion. Dispatches to appropriate handler based on schema type (object, array, string, number, enum, etc.). Recursively processes nested schemas and generates corresponding GBNF rules.
- Parameters
-
| schema | Schema node to convert (JSON object, may contain type, properties, items, etc.) |
| name | Rule name to generate (used as identifier in output grammar) |
- Returns
- Generated GBNF rule definition
- Note
- Accumulates errors in _errors vector - call check_errors() after conversion
-
May throw std::runtime_error on unrecognized schema constructs
- Warning
- Complex method (~200+ lines) - handles all JSON Schema type keywords
Definition at line 1032 of file json-schema-to-grammar.hpp.
◆ lloyal::build_grammar
The documentation for this class was generated from the following file: