Skip to content

Commit

Permalink
add json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
hnkisdead authored and umputun committed Jul 18, 2023
1 parent 9946c6c commit fd93c56
Show file tree
Hide file tree
Showing 4 changed files with 498 additions and 0 deletions.
Binary file added schemas/IDEA-add-custom-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions schemas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Schemas

JSON Schema definitions for inventory and playbook

# VSCode setup

1. Install [plugin](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) for YAML support
2. Associate schemas with files - [documentation](https://github.com/redhat-developer/vscode-yaml#associating-a-schema-in-the-yaml-file)
Example
```json
{
"yaml.schemas": {
"https://raw.githubusercontent.com/umputun/spot/master/schemas/inventory.json": "inventory.yml",
"https://raw.githubusercontent.com/umputun/spot/master/schemas/playbook.json": "spot.yml"
}
}
```

# IDEA-based IDE setup

1. Add custom JSON Schema - [documentation](https://www.jetbrains.com/help/idea/json.html#ws_json_schema_add_custom)
Example
![Example](IDEA-add-custom-schema.png)
72 changes: 72 additions & 0 deletions schemas/inventory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://raw.githubusercontent.com/umputun/spot/master/schemas/inventory.json",
"title": "Spot Inventory",
"description": "Spot Inventory",
"type": "object",
"additionalProperties": false,
"oneOf": [
{
"required": [
"hosts"
]
}, {
"required": [
"groups"
]
}
],
"properties": {
"hosts": {
"type": "array",
"additionalItems": false,
"items": {
"$ref": "#/definitions/host"
}
},
"groups": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
".*": {
"type": "array",
"items": {
"$ref": "#/definitions/host"
}
}
}
}
},
"definitions": {
"host": {
"type": "object",
"additionalProperties": false,
"required": [
"host"
],
"properties": {
"name": {
"type": "string"
},
"host": {
"type": "string"
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535,
"default": 22
},
"user": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
Loading

0 comments on commit fd93c56

Please sign in to comment.