schema_to_glua 0.1.5

Tooling for converting JSON Schema into GLua annotations.
Documentation
  • Coverage
  • 37.5%
    3 out of 8 items documented0 out of 1 items with examples
  • Size
  • Source code size: 38.09 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 38s Average build duration of successful builds.
  • all releases: 38s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Pollux12/gmod-glua-ls
    4 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Pollux12

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):

cargo install schema_to_glua

CLI Usage

Convert schema.json to stdout:

schema_to_glua schema_to_glua <schema.json> [output.lua]

Library Usage (Example)

Add dependency (Cargo.toml):

schema_to_glua = "0.1.0"

Example code:

let schema = r#"
{
    "type": "object",
    "properties": {
        "name": { "type": "string" },
        "age": { "type": "integer" }
    },
    "required": ["name"]
}
"#;

let converter = SchemaConverter::new(true);
let emmylua = converter.convert_from_str(&schema);

Input Example (schema.json)

{
    "type": "object",
    "properties": {
        "name": { "type": "string" },
        "age": { "type": "integer" },
        "tags": {
            "type": "array",
            "items": { "type": "string" }
        }
    },
    "required": ["name"]
}

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.