# JSON Schema for \`viktor.config.toml\`

**URL:** <https://community.viktor.ai/t/json-schema-for-viktor-config-toml/1354>\
**Category:** Feature Requests\
**Created:** [24 October 2023 11:50 UTC](https://community.viktor.ai/t/json-schema-for-viktor-config-toml/1354 "2023-10-24T11:50:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkg](https://community.viktor.ai/user_avatar/community.viktor.ai/rkg/32/485_2.png) [@rkg](https://community.viktor.ai/u/rkg)\
**Post date:** [24 October 2023 11:50 UTC](https://community.viktor.ai/t/json-schema-for-viktor-config-toml/1354/1 "2023-10-24T11:50:47Z")

</div>

## Description of the limitation and why it is relevant to address

As a developer I want to be assisted in editing `viktor.config.toml` in my code editor, so I’m sheltered from typo or other mistakes.

I think this is relevant for the VIKTOR platform because it prevent “silly” errors, which will only show up once a developer tries to publish an app.

I’m aware it’s a really small and niche “feature”, so perhaps the workaround is fine.

## Submitter proposed design

I’m using the [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) extension in VS Code, that support schema validation through schema json files. Below is an example I made.

By specifying the schema, it can validate the content of the tom file. Here’s a screenshot of a typo I hadn’t noticed before. Apparently I missed the “s” in `assets_path`

 ![image](https://community.viktor.ai/uploads/default/original/1X/55fa3099e12111491343440bde50d66130836d9d.png)

It would be nice if the schema could be uploaded to [json-schema.org](https://json-schema.org/), so we developers can all use the same schema. In that way you could update the schema once there are new options.

### Example schema

```json
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Viktor configuration file",
    "description": "The `viktor.config.toml` file is used to set configuration settings for your app, and is placed on the top-level of the application folder.",
    "type": "object",
    "properties": {
        "app_type": {
            "description": "The type of app",
            "type": "string",
            "enum": [
                "editor",
                "simple",
                "tree"
            ]
        },
        "assets_path": {
            "description": "Defines the directory where assets (e.g. images) are stored",
            "type": "string"
        },
        "enable_privileged_api": {
            "description": "With this key, the application code is able to bypass user access restrictions",
            "type": "boolean"
        },
        "python_version": {
            "description": "Specify the Python version to publish the application with",
            "type": "string",
            "enum": [
                "3.8",
                "3.9",
                "3.10",
                "3.11"
            ]
        },
        "welcome_text": {
            "description": "A welcome text can be customized, which will be shown to the user upon entering the application dashboard. The value is a path pointing to a file located relative to viktor.config.toml. The file supports styling with Markdown.",
            "type": "string"
        }
    },
    "required": [
        "app_type"
    ],
    "additionalProperties": false
}

```

## Current workarounds

Manually check the file, or try to publish it. Or use the above schema just locally.

---

<div class="post-metadata">

**Author:** ![matthijs](https://community.viktor.ai/user_avatar/community.viktor.ai/matthijs/32/34_2.png) [@matthijs](https://community.viktor.ai/u/matthijs)\
**Post date:** [26 October 2023 07:52 UTC](https://community.viktor.ai/t/json-schema-for-viktor-config-toml/1354/2 "2023-10-26T07:52:06Z")

</div>

Thanks for your feature request! Can imagine this makes it easier.

Is it also possible to use local schemas? That way developers can already use your schema.

BTW: [the `create-app`](https://docs.viktor.ai/docs/create-apps/references/cli/#create-app) command also creates a config with commented out attributes, so using that might already help for those not aware.

---

<div class="post-metadata">

**Author:** ![rkg](https://community.viktor.ai/user_avatar/community.viktor.ai/rkg/32/485_2.png) [@rkg](https://community.viktor.ai/u/rkg)\
**Post date:** [26 October 2023 09:06 UTC](https://community.viktor.ai/t/json-schema-for-viktor-config-toml/1354/3 "2023-10-26T09:06:57Z")

</div>

Yes, it’s possible to use the schema locally. I saved the schema as `viktor-config-toml.schema.json` next to the toml file, like

```auto
my-folder
├── app.py
├── requirements.txt
└── viktor.config.toml
└── viktor-config-toml.schema.json

```

And added this first line in the toml file

```auto
#:schema viktor-config-toml.schema.json

```

An example `viktor.config.toml` file would be:

```toml
#:schema viktor-config-toml.schema.json
app_type = 'tree'
python_version = '3.10'
enable_privileged_api = false
welcome_text = "CHANGELOG.md"
assets_path = "assets"

```

The `schema` directive was taken from [documentation](https://taplo.tamasfe.dev/configuration/directives.html#the-schema-directive) from the library used in the extensions.

But; I haven’t yet tested if `viktor-cli publish` aceepts that extra line.
