TYML is a schema language that provides type checking and editor assistance for arbitrary configuration languages. It currently supports the following configuration languages:
ini
toml
json
TYML is designed to be more intuitive yet more precise than competing specifications such as JsonSchema
.
It can also define REST API schemas similar to OpenAPI
.
Here is a quick look at the syntax TYML uses.
// "setting" is the setting name and "int" is its type
setting: int
/// Triple slashes "///" are treated as documentation comments
/// (They are recognized by the LSP and can be shown while editing.)
///
/// "[Setting]" means an array of type "Setting"
settings:
/// You can define a struct type "Setting"
type Setting
/// Defining an enum restricts values to the specified strings
enum Mode
/// Appending "?" to a type makes the value optional
/// This is the soโcalled nullable/optional type
nullable: int?
/// Using "|" creates a union type: a value of either side is accepted
or_type: int | string
/// You can also define REST APIs!
/// Code can of course be generated with the type generator (tyml-api-generator).
/// The docs you write here are propagated into the generated output.
interface API
You can enable type checking and editor help in your config file by referencing the schema like this:
# !tyml example.tyml
# Specify the schema file by adding "!tyml" in a comment
= 100
[[]]
= "192.168.1.1"
= 25565
= "Debug"
= 200