Giter Club home page Giter Club logo

better-stronger-toml's Introduction

better-stronger-toml

A VS Code extension allowing syntax validation for TOML and schema validation using Json and Hjson.

It is currently in preview, report bugs on Github.

Features

  • Syntax validation for TOML 1.0.0
  • Schema validation with Json Schema draft-2020-12
  • Default schema & glob pattern associations with schema
  • Loading schema in Json or Hjson
  • Partial support of auto-completion using the schema (it use only first level properties of the schema) & limited to property keys only
    • Types (including the $ref), the description & examples are indicated
  • Syntax Hightlighting is not supported yet, but other extensions providing this feature only are available, you can use them conjointly with this extension

TOML

TOML is a simple data format, usually used for configuration files, this extension provide syntaxic correction for it.

id = 10
owner = "John Doe"

[server]
enabled = true
hostname = "localhost"
port = 8080

Json schema

The extension allow you to use usual Json schema.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Server schema",
  "description": "Simple schema of a server",
  "type": "object",
  "properties": {
    "id": {
      "description": "The unique identifier of a server",
      "type": "integer"
    },
    "owner": {
      "description": "Owner of the server",
      "type": "string"
    },
    "server": {
      "description": "Configuration of the server",
      "$ref": "#/definitions/Server"
    }
  },
  "required": ["id", "owner", "server"],
  "definitions": {
    "Server": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "localhost": {
          "type": "string"
        },
        "port": { 
          "type": "integer",
          "minimum": 1024,
          "maximum": 65535
        }
      },
      "title": "Configuration of the server",
      "required": [ "hostname", "port" ]
    }
  }
}

Hjson schema

The extension allow you to specify the schema with a less verbose syntax than Json : Hjson.

{
  // You can use comments
  # Properties do not need quotes
  $schema: "http://json-schema.org/draft-04/schema#",
  /* Strings do not need quotes */
  title: Server schema
  type: "object"
  // You do not need commas
  description: "Simple schema of a server"
  properties: {
    id: {
      description: The unique identifier of a server
      type: integer
    }
    owner: {
      description: Owner of the server
      type: "string"
    }
    server: {
      description: "Configuration of the server"
      $ref: "#/definitions/Server"
    }
  }
  required: ["id", "owner", "server"]
  definitions: {
    Server: {
      type: "object"
      additionalProperties : true
      properties: {
        "enabled": {
          "type" : "boolean"
        },
        localhost: {
          "type": "string"
        },
        port: { 
          type: "integer",
          minimum: 1024,
          maximum: 65535
        }
      }
      title : "Configuration of the server"
      required : [ "hostname", "port" ]
    }
  }
}

Requirements

If you have any requirements or dependencies, add a section describing those and how to install and configure them.

Extension Settings

This extension contributes the following settings:

  • betterStrongerToml.jsonSchema.enabled: enable/disable usage of schemas
  • betterStrongerToml.jsonSchema.defaultSchema: default schema to use, example : "./schema.json"
  • betterStrongerToml.jsonSchema.associations: associations between a glob pattern ("**/*.server.toml" for instance) and a schema

Known Issues

If the extension do not seem to be starting (Runtime status : Not yet activated.), you need to associate the file extension .toml to the language toml.

Schema constraints are reported at the first line instead of their actual location, but the path is indicated.

Auto-completion using the schema is limited to first level properties (not those included in the definitions) & are limited to property keys.

Release Notes

Users appreciate release notes as you update your extension.

0.0.1

  • Initial release of Better Stronger TOML (preview).

0.0.2

  • Fixing minor issues (package.json, README.md).

0.0.3

  • Added first version of auto-completion
    • Limited to first level properties of the schema (properties of definitions are not used)
    • Limited to property keys
    • Description is indicated
    • Examples are indicated
    • Types are indicated, the $ref is also indicated
    • Contrainsts are not indicated

better-stronger-toml's People

Contributors

isirode avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

nazarpunk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.