schema_to_glua
A tool and library that converts JSON Schema into GLua annotations.
Concise and suitable for automatically generating Lua/GLua comments from backend or normalized JSON Schema (for IDE type hints and static checking).
Features
- Supports basic JSON Schema types: object, array, string, number, integer, boolean, null
- Generates @class, @field, @alias and other GLua annotations
- Provides CLI and library interfaces, can be embedded into build pipelines
Install / Build
Build via Rust (requires Rust toolchain):
CLI Usage
Convert schema.json to stdout:
Library Usage (Example)
Add dependency (Cargo.toml):
= "0.1.0"
Example code:
let schema = r#"
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" }
},
"required": ["name"]
}
"#;
let converter = new;
let emmylua = converter.convert_from_str;
Input Example (schema.json)
Generated GLua Example
---@class Person
---@field public name string
---@field public age integer|nil
---@field public tags string[]|nil
License
MIT License
Forked from EmmyLua Analyzer Rust.