Skip to content

shaburov/jetbrains-ide-json-schema-live-templates

Repository files navigation

JetBrains Live Templates for json schemas Project

Templates:

  • json-schema4json.xml (json files)
  • json-schema4yaml.xml (yaml files)

Copy templates to JetBrains IDE configuration directory and restart the IDE:
Linux /home/<username>/.config/JetBrains/<IDE name>/templates/*
MacOS /Users/<username>/Library/Preferences/<IDE name>/templates/*
Windows C:\Users\<username>\<IDE name>\templates\*

Result:
Settings.png

Template commands

Schema file

1ObjectSchema

WantObjectSchema.gif

Template body click to expand
{
  "$schema": "http://json-schema.org/draft-$draft$/schema#",
  "id": "$schema_id$",
  "title": "$title$",
  "description": "$description$",
  "type": "object",
  "properties": {
    "$_1$": {
      $END$
    }
  },
  "required": [
    "$_1$"
  ]
}

1ArraySchema

WantArraySchema.gif

Template body click to expand
{
  "$schema": "http://json-schema.org/draft-$draft$/schema#",
  "id": "$schema_id$",
  "title": "$title$",
  "description": "$description$",
  "type": "array",
  "minItems": $minItems$,
  "maxItems": $maxItems$,
  "uniqueItems": $uniqueItems$,
  "items": {
    $END$
  }
}

Schema properties

1Object

Scripts.gif

Template body click to expand
"type": "object",
"description": "$description$",
"properties": {
  "$_1$": {
    $END$
  }
},
"required": [
  "$_1$"
]

1Array

WantArray.gif

Template body click to expand
"type": "array",
"description": "$description$",
"minItems": $minItems$,
"maxItems": $maxItems$,
"uniqueItems": $uniqueItems$,
"items": {
  $END$
}

1Integer

WantInteger.gif

Template body click to expand
"type": "integer",
"description": "$description$",
"minimum": $minimum$,
"maximum": $maximum$,
"multipleOf": $multipleOf$,
"default": $default$

1Number

WantNumber.gif

Template body click to expand
"type": "number",
"description": "$description$",
"minimum": $minimum$,
"maximum": $maximum$,
"multipleOf": $multipleOf$,
"default": $default$

1String

WantString.gif

Template body click to expand
"type": "string",
"description": "$description$",
"minLength": $minLength$,
"maxLength": $maxLength$,
"pattern": "$pattern$"

1Boolean

WantBoolean.gif

Template body click to expand
"type": "boolean",
"description": "$description$",
"default": $default$

Schema formats

1utcMillisecFormat

"type": "number",
"format": "utc-millisec",
"description": "$description$"

1uuidFormat

"type": "string",
"format": "uuid",
"description": "$description$"

Helper template

If you need to write groovyScripts yourself, the following template may come in handy.
The code below escapes the copied groovyScript for later use in template variables.

groovyScript("def str = _1.replace(\"\\n\", \"\"); while (str.contains(\"  \")) { str = str.replace(\"  \", \" \"); }; str = str.replace(\"\\\"\", \"\\\\\\\"\"); return \"groovyScript(\\\"\"+str+\"\\\")\"", clipboard())

2EscapeGroovyScript.gif

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages