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

Add JSON schema for config file #1864

Merged

Conversation

binyamin
Copy link
Contributor

@binyamin binyamin commented Sep 16, 2022

Provides a JSON schema for the wails.json config

Resolves #1851

Notes

Along with publishing a schema, I feel that a few more things would be useful

  • A project member should probably ensure the schema is accurate
    • I tried my best to review the docs & code, but it's always best to be safe
  • When the user runs wails init, the config file it creates should include a link to the schema
  • The website should note that the schema exists. Maybe on /docs/reference/project-config.

@leaanthony
Copy link
Member

Hey @binyamin 👋 Apologies for being a bit slow getting back to you on this. Happy to review this. What did you mean by The wails init command should link to the schema in the config file it creates?
Feel free to update the docs in the website directory and let me know if you need a hand with that 👍

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

Looks good so far! Just a couple of comments. Thanks so much 🙏

website/static/schemas/config.v2.json Outdated Show resolved Hide resolved
},
"definitions": {
"OsHook": {
"title": "GOOS/*",
Copy link
Member

Choose a reason for hiding this comment

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

So these osHook keys are actually the format of the keys rather than explicit values, EG: windows/* or linux/arm7. I'm not sure how you represent that in JSONSchema!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I could have validated it against a list of all possible os and arch values. Instead, I chose to add some dummy keys for explanation (lines 182 - 190). The keys are matched against a RegExp at lines 192 - 202.

Just FYI, the title key is mainly used for intellisense & documentation. It's doesn't mean you actually use "title" in the schema.

@binyamin
Copy link
Contributor Author

What did you mean by The wails init command should link to the schema in the config file it creates?

I edited the top comment. Let me know if it's still unclear.

@leaanthony
Copy link
Member

Do you mean update the generated wails.json files to include the schema reference? What would that look like for e.g. this file? If you give me an example, I can do some search+replace fu 👍

@binyamin
Copy link
Contributor Author

@leaanthony it would look like this:

{
  "$schema": "https://wails.io/schema/config.v2.json",
  "name": "{{.ProjectName}}",
  // ...
}

@leaanthony
Copy link
Member

@binyamin - I've added the schema references + updated the docs. Let me know if you feel this is good to go and we'll get it merged 👍

@leaanthony
Copy link
Member

Let's go!

@leaanthony leaanthony marked this pull request as ready for review October 22, 2022 10:05
@leaanthony leaanthony merged commit 4bff4af into wailsapp:master Oct 22, 2022
@leaanthony
Copy link
Member

Thanks for taking the time to do this. It's a fantastic addition 👍

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.

Provide a JSON schema for Wails' project config
2 participants