https://github.com/finitereality/xinji
A scheming schema definition language
https://github.com/finitereality/xinji
Last synced: about 1 month ago
JSON representation
A scheming schema definition language
- Host: GitHub
- URL: https://github.com/finitereality/xinji
- Owner: FiniteReality
- License: mit
- Created: 2021-03-17T04:07:20.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-27T11:59:13.000Z (about 5 years ago)
- Last Synced: 2025-01-10T20:53:03.546Z (over 1 year ago)
- Language: Lua
- Size: 14.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: docs/README.md
- License: LICENSE
Awesome Lists containing this project
README
# 心计 - A scheming schema definition language #
心计 (Xīnjì, pronounced /ɕīntɕìː/, or if you can't read IPA, "shinji" is close
enough) is a schema definition language designed to be used as the
single-source-of-truth of types used in a microservices application involving
multiple applications.
## How does it work? ##
心计 lets you define types using Lua code, which means you're free to use all of
the Lua facilities to augment your schema, as a form of metaprogramming. As an
example:
```lua
primitive "bool"
primitive "float"
primitive "string"
primitive "uint8"
primitive "uint64"
-- an optional value
function optional(valueType)
local result = union {
kind = { "union", "optional" }
valueType,
null
}
return result
end
class "item" {
uint64 "id",
string "name",
enum(uint8) "category" {
"armor",
"weapon",
"ammo",
"consumable",
}
}
class "player" {
uint64 "id",
string "name",
tuple(float, float, float) "position",
array(3 * 9, optional(item)) "inventory"
}
```