|
1 |
| -[](https://jsnac.readthedocs.io/en/latest/?badge=latest) |
2 | 1 | 
|
| 2 | +[](https://jsnac.readthedocs.io/en/latest/?badge=latest) |
| 3 | + |
3 | 4 |
|
4 | 5 | # JSNAC
|
5 |
| -JSON Schema (for) Network as Code |
| 6 | +JSON Schema (for) Network Automation Creator |
| 7 | + |
| 8 | +- [Overview](#overview) |
| 9 | +- [Brief Example](#brief-example) |
| 10 | +- [YAML Validation](#yaml-validation) |
| 11 | +- [Detailed Example](#detailed-example) |
| 12 | +- [Usage](#usage) |
6 | 13 |
|
7 | 14 | ## Overview
|
8 | 15 |
|
@@ -81,6 +88,30 @@ schema:
|
81 | 88 | kind: { name: "ipv6_cidr" }
|
82 | 89 | ```
|
83 | 90 |
|
| 91 | +```bash |
| 92 | +(.venv) user@server:~/jsnac$ jsnac -f data/example-jsnac.yml |
| 93 | +[INFO] - jsnac - Starting JSNAC CLI |
| 94 | +[INFO] - jsnac - Schema built in 0.0006 seconds |
| 95 | +[INFO] - jsnac - Schema written to: jsnac.schema.json |
| 96 | +[INFO] - jsnac - JSNAC CLI complete |
| 97 | +``` |
| 98 | + |
| 99 | +## YAML Validation |
| 100 | + |
| 101 | +To be able to validate the orginal YAML file or any new YAML file you create using this schema you first need to reference your JSON schema using the yaml-language-server comment at the top of your YAML file |
| 102 | + |
| 103 | +```yaml |
| 104 | +# yaml-language-server: $schema=jsnac.schema.json |
| 105 | +--- |
| 106 | +chassis: |
| 107 | + hostname: "hostname" |
| 108 | +``` |
| 109 | +
|
| 110 | +Which language server you use is specific to your environment and editor that you use. For Visual Studio Code I recommend that you use the [Red Hat YAML Language Server](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) extension. Once installed you will now see that you will have automatic code completion, syntax highlighting, schema validation etc. while editing your YAML file. |
| 111 | +
|
| 112 | +
|
| 113 | +## Detailed Example |
| 114 | +
|
84 | 115 | We also have full support for writing your own titles, descriptions, kinds (sub-schemas), objects that are required, etc. A more fleshed out example of the same schema is below:
|
85 | 116 |
|
86 | 117 | ```yaml
|
@@ -161,7 +192,7 @@ schema:
|
161 | 192 | required: [ "if" ]
|
162 | 193 | ```
|
163 | 194 |
|
164 |
| -A full list of kinds are available in the  |
| 195 | +A full list of kinds are available in the [documentation](https://jsnac.readthedocs.io/en/latest/) |
165 | 196 |
|
166 | 197 | ## Usage
|
167 | 198 |
|
|
0 commit comments