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

Initial JSON schema #58

wants to merge 1 commit into from

Conversation

nick7
Copy link

@nick7 nick7 commented Jan 22, 2022

What about some schemas?

  • schema/game.json for [game]/[game].json files,
  • schema/enums.json for [game]/enums.json files.

If you want to use it you should reference schemas in your .json files.
I'm not sure about directory and file naming. I'm not sure is it ok to reference schemas directly from github. It's more like proof-of-concept.

How-To

In short, with schema you can do some interesting things:

  • Validate JSON structure.
  • Use predictions and hints in your text editor.

By default, schema should be specified in $schema property. So you can copy and paste code below and try it by yourself.

{
  "$schema": "https://raw.githubusercontent.com/nick7/library/master/schema/game.json",
  ...
}

In Visual Studio you can type schema directly into special field:
schema

@x87
Copy link
Contributor

x87 commented Jan 22, 2022

Interesting idea. I did not think about editing JSON files outside of the editor (/editor folder). The editor has all validations in place. and is also capable of updating related commands (the commands that have the same name and parameters in multiple games) in one batch. When you edit JSON file directly you risk to get the information diverged.

However I don't think having a schema would harm anyone. I guess it may help in those rare cases when you absolutely need to make a raw edit.

"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.

@nick7
Copy link
Author

nick7 commented Jan 23, 2022

Main problem is keeping schema up to date. If it's not intended to be used it's easy to forget about it.

So if we want it to add, we need someone to keep it up to date. ¯\(ツ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants