JetBrains Live Templates for json schemas
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\*
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$"
]
}
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$
}
}
Template body click to expand
"type": "object",
"description": "$description$",
"properties": {
"$_1$": {
$END$
}
},
"required": [
"$_1$"
]
Template body click to expand
"type": "array",
"description": "$description$",
"minItems": $minItems$,
"maxItems": $maxItems$,
"uniqueItems": $uniqueItems$,
"items": {
$END$
}
Template body click to expand
"type": "integer",
"description": "$description$",
"minimum": $minimum$,
"maximum": $maximum$,
"multipleOf": $multipleOf$,
"default": $default$
Template body click to expand
"type": "number",
"description": "$description$",
"minimum": $minimum$,
"maximum": $maximum$,
"multipleOf": $multipleOf$,
"default": $default$
Template body click to expand
"type": "string",
"description": "$description$",
"minLength": $minLength$,
"maxLength": $maxLength$,
"pattern": "$pattern$"
Template body click to expand
"type": "boolean",
"description": "$description$",
"default": $default$
"type": "number",
"format": "utc-millisec",
"description": "$description$"
"type": "string",
"format": "uuid",
"description": "$description$"
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())