Skip to content

Commit

Permalink
Merge pull request #90 from Flow-Launcher/add-json-schema-info
Browse files Browse the repository at this point in the history
Add information on using JSON schemas
  • Loading branch information
jjw24 authored Nov 21, 2024
2 parents 96c3257 + df8fdfe commit 8cacb4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions json-rpc-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ body:
<settings-component-demo type="dropdown" label="Programming language to prefer for answers" value="TypeScript" options='["JavaScript", "TypeScript", "Python", "C#"]'></settings-component-demo>
<settings-component-demo type="checkbox" label="Prefer shorter answers" description="If checked, the plugin will try to give answer much shorter than the usual ones."></settings-component-demo>

### JSON Schema
Add the following line at the beginning of your `SettingsTemplate.yaml` file to enable validation and auto-completion in your IDE. Unfortunately, this feature is supported only in JetBrains IDEs (WebStorm, PhpStorm, Rider, etc.) and does not work in Visual Studio or Visual Studio Code. Please note that it must start with `#` as it must be a comment, otherwise Flow Launcher won't be able to parse the file.

```yaml
#$schema: https://www.flowlauncher.com/schemas/settings-template.schema.json
```

### Visual editor for `SettingsTemplate.yaml`
You can use a [visual editor](/json-rpc-visual-settingstemplate-editor.md) for creating the `SettingsTemplate.yaml` file. When you're done editing, click the `Generate SettingsTemplate.yaml` file and copy-paste its contents into your `SettingsTemplate.yaml` file. Optionally, you can also copy the generated typings for your settings object in your preferred programming language.

Expand Down
13 changes: 13 additions & 0 deletions plugin.json.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ It must be in the plugin root directory.
"ExecuteFileName":"" //Execution entry. dll extension for C#/F# plugin, .py for python plugin, .js/.ts for JS/TS plugins and .exe or other executable for executable plugin. Path examples include "main.py" or "./dist/main.js"
}
```

## JSON Schema
Additionally, you can add a property called `$schema` to enable validation and auto-completion in your IDE. This works in JetBrains IDEs (i.e., WebStorm, PhpStorm, Rider, etc.), Visual Studio, and Visual Studio Code. Add this property to the top of the JSON file:

```js
{
"$schema": "https://www.flowlauncher.com/schemas/plugin.schema.json",
// the rest of the plugin.json file
// ...
}
```

Now you should have auto-completion and file validation available for you in your IDE.

0 comments on commit 8cacb4f

Please sign in to comment.