Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial JSON schema #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions schema/enums.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"properties": {
"$schema": {
"type": "string"
}
},
"patternProperties": {
"^[A-Z0-9][A-Za-z0-9_]+$": {
"type": "object",
"patternProperties": {
"^[A-Z0-9][A-Za-z0-9_]+$": {
"anyOf": [
{
"type": "null"
},
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
"additionalProperties": false
}
},
"additionalItems": false
}
238 changes: 238 additions & 0 deletions schema/game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"definitions": {
"url": {
"type": "string",
"pattern": "^(http|https|ftp)://([a-zA-Z\\.\\d/#?=%+_]+)$"
},
"type_name": {
"description": "CamelCase type name",
"type": "string",
"pattern": "^[A-Z][a-zA-Z0-9]+$"
},
"extension": {
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^[a-zA-Z0-9_\\-]+$"
},
"commands": {
"type": "array",
"items": {
"$ref": "#/definitions/command"
}
}
},
"required": [ "name", "commands" ],
"additionalProperties": false
},
"command": {
"description": "Command definition",
"type": "object",
"properties": {
"id": {
"description": "Opcode unique identifier",
"type": "string",
"pattern": "^[0-9a-fA-F]{4}$"
},
"name": {
"description": "Opcode unique name (Rockstar fashion)",
"pattern": "^([A-Z0-9_]+|{|})$"
},
"num_params": {
"description": "Total parameter count",
"type": "integer",
"minimum": 0,
"maximum": 20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maximum is unset, however normally it would be 16 params in 3/VC and 32 in San Andreas

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, it's my mistake. It should be increased. I wanted to add reasonable limit to make schema stronger.

},
"input": {
"type": "array",
"items": {
"$ref": "#/definitions/command_parameter"
}
},
"output": {
"type": "array",
"items": {
"$ref": "#/definitions/command_parameter"
}
},
"short_desc": {
"type": "string"
},
"attrs": {
"$ref": "#/definitions/command_attributes"
},
"class": {
"type": "string"
},
"member": {
"type": "string"
},
"platforms": {
"type": "array"
},
"versions": {
"type": "array"
}
},
"required": [ "id", "name", "num_params" ],
"additionalProperties": false
},
"command_parameter": {
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^([a-zA-Z_0-9]+|)$"
},
"type": {
"$ref": "#/definitions/parameter_type"
},
"source": {
"type": "string"
}
},
"required": [ "name", "type" ],
"additionalProperties": false
},
"command_attributes": {
"description": "Command attributes",
"type": "object",
"properties": {
"is_branch": {
"description": "This command branches the code",
"type": "boolean"
},
"is_condition": {
"description": "This command can be used in conditional statements",
"type": "boolean"
},
"is_constructor": {
"description": "This command creates a new in-game entity",
"type": "boolean"
},
"is_destructor": {
"description": "This command deletes the in-game entity",
"type": "boolean"
},
"is_keyword": {
"description": "This command is used as a single keyword followed by arguments",
"type": "boolean"
},
"is_nop": {
"description": "This command is a no-operation",
"type": "boolean"
},
"is_overload": {
"description": "This command has multiple variations for different types of arguments",
"type": "boolean"
},
"is_segment": {
"description": "This command is used to separate segments in SCM header",
"type": "boolean"
},
"is_static": {
"description": "This command operates on a static property or in-game entity that can not be constructed dynamically",
"type": "boolean"
},
"is_unsupported": {
"description": "This command is unsupported in the given game and its usage is forbidden",
"type": "boolean"
},
"is_variadic": {
"description": "This command has variadic number of arguments",
"type": "boolean"
}
},
"additionalProperties": false
},
"parameter_type": {
"anyOf": [
{
"description": "Basic type",
"enum": [
"any",
"arguments",
"bool",
"script_id",
"float",
"gxt_key",
"int",
"label",
"model_any",
"model_char",
"model_object",
"model_vehicle",
"string",
"string128",
"zone_key"
]
},
{
"description": "Enumeration name",
"$ref": "#/definitions/type_name"
}
]
},
"class": {
"type": "object",
"properties": {
"name": {
"description": "Class name",
"$ref": "#/definitions/type_name"
},
"constructable": {
"type": "boolean"
},
"desc": {
"type": "string"
},
"extends": {
"$ref": "#/definitions/type_name"
}
},
"required": [ "name", "constructable", "desc" ],
"additionalProperties": false
}
},
"type": "object",
"properties": {
"$schema": {
"type": "string"
},
"meta": {
"description": "Meta-information",
"type": "object",
"properties": {
"last_update": {
"description": "Timestamp",
"type": "integer"
},
"version": {
"type": "string",
"pattern": "^[\\d\\.]+$"
},
"url": {
"$ref": "#/definitions/url"
}
},
"additionalProperties": false
},
"extensions": {
"type": "array",
"items": {
"$ref": "#/definitions/extension"
}
},
"classes": {
"type": "array",
"items": {
"$ref": "#/definitions/class"
}
}
},
"required": [ "meta", "extensions" ],
"additionalProperties": false
}