Feedback: Enum/Select in schema fields #679

Closed
opened 2026-10-05 02:59:59 +02:00 by adam · 5 comments
Owner

I am adding this as feedback, because I don't know if it is maybe integrated or I am overlooking something...

Let's assume I have a data file with a blogroll, and in that blogroll I want to add a field that demarks what type of link that item is: how do I implement some form of enum or select for that field? For instance ["person", "website", "feed"] or something along the lines and in frontmatter it shows either three radio boxed items in a line that I can select one, or a select field with three items (and their labels)?

In JSON schema we have enum:

properties:
  type:
    type: string
    enum:
      - blog
      - video
      - music
      - page
      - documentation

But it doesn't seem that this is integrated. At least the docs are not talking about it and trying some forms of settings on JSON-"schema" values won't work.

I am adding this as feedback, because I don't know if it is maybe integrated or I am overlooking something... Let's assume I have a data file with a blogroll, and in that blogroll I want to add a field that demarks what type of link that item is: how do I implement some form of enum or select for that field? For instance `["person", "website", "feed"]` or something along the lines and in frontmatter it shows either three radio boxed items in a line that I can select one, or a select field with three items (and their labels)? In JSON schema we have enum: ```yaml properties: type: type: string enum: - blog - video - music - page - documentation ``` But it doesn't seem that this is integrated. At least the docs are not talking about it and trying some forms of settings on JSON-"schema" values won't work. <!-- github-sync-id:2559221188 -->
adam closed this issue 2026-10-05 02:59:59 +02:00
Author
Owner

This is getting messy, sorry... I experimented around some more and have now this:

      "schema": {
        "properties": {
          "type": {
            "title": "Type",
            "type": "string",
            "enum": ["blog", "podcast", "youtube"]
          }
        },

but it results in this:

image

The title attribute is part of the dropdown.

Also: The resulting json in the datafile is missing the type field (when selecting "Type" as well as one of the "enum" values):

[
  {
    "link": "fgsdfsds",
    "description": "sdf",
    "name": "sdf"
  }
]
This is getting messy, sorry... I experimented around some more and have now this: ```json "schema": { "properties": { "type": { "title": "Type", "type": "string", "enum": ["blog", "podcast", "youtube"] } }, ``` but it results in this: ![image](https://github.com/user-attachments/assets/2aa673d5-9c73-4728-968a-73b5a7f07319) The title attribute is part of the dropdown. Also: The resulting json in the datafile is missing the type field (when selecting "Type" as well as one of the "enum" values): ```json [ { "link": "fgsdfsds", "description": "sdf", "name": "sdf" } ] ``` <!-- github-comment-id:2385852345 -->
Author
Owner

Complete config for that data type:

  "frontMatter.data.files": [
    {
      "file": "[[workspace]]/data/dnb/kollitsch/blogroll.json",
      "fileType": "json",
      "id": "blogroll",
      "labelField": "name",
      "title": "Blogroll",
      "schema": {
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "description": {
            "multiline": true,
            "title": "Description",
            "type": "string"
          },
          "link": {
            "title": "Link",
            "type": "string"
          },
          "type": {
            "title": "Type",
            "type": "string",
            "enum": ["blog", "podcast", "youtube"]
          }
        },
        "required": ["name", "link"],
        "type": "object"
      }
    }
  ],
Complete config for that data type: ```json "frontMatter.data.files": [ { "file": "[[workspace]]/data/dnb/kollitsch/blogroll.json", "fileType": "json", "id": "blogroll", "labelField": "name", "title": "Blogroll", "schema": { "properties": { "name": { "title": "Name", "type": "string" }, "description": { "multiline": true, "title": "Description", "type": "string" }, "link": { "title": "Link", "type": "string" }, "type": { "title": "Type", "type": "string", "enum": ["blog", "podcast", "youtube"] } }, "required": ["name", "link"], "type": "object" } } ], ``` <!-- github-comment-id:2385872263 -->
Author
Owner

This came up again. It would really be quite nice to have a field where we can select (one or more items) from a pre-filled selection.

This came up again. It would really be quite nice to have a field where we can select (one or more items) from a pre-filled selection. <!-- github-comment-id:2439165977 -->
Author
Owner

Implemented the change, let me know if this fixed it in the beta.

Implemented the change, let me know if this fixed it in the beta. <!-- github-comment-id:2441628263 -->
Author
Owner

works perfect in the beta :) thank you!

works perfect in the beta :) thank you! <!-- github-comment-id:2443499655 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#679