Skip to content

Commit

Permalink
chore: add schema validation docs (#748)
Browse files Browse the repository at this point in the history
Co-authored-by: @Racer159 <wayne@defenseunicorns.com>
Co-authored-by: Tristan Holaday <40547442+TristanHoladay@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 1, 2024
1 parent 8232540 commit a696ffc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Binary file added docs/.images/goland-json-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions docs/schema-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Schema Validation

When working with UDS configuration files, it can be useful to setup your IDE to know about the various schemas that UDS uses.

The recommended method of validating schemas is by the use of `yaml-language-server` file headers:

For `uds-bundle.yaml`
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/defenseunicorns/uds-cli/main/uds.schema.json
```

For `zarf.yaml`
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/defenseunicorns/uds-cli/main/zarf.schema.json
```

For `tasks.yaml`
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/defenseunicorns/uds-cli/main/tasks.schema.json
```

This method works with both VSCode and Goland (Jetbrains IDEs).

### Other IDE-specific Methods

### VS Code

To do this in VS Code you can install the [YAML Extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) and add the following to your `settings.json` (pinning `main` to your UDS CLI version if desired):

```json
"yaml.schemas": {
"https://raw.githubusercontent.com/defenseunicorns/uds-cli/main/uds.schema.json": "uds-bundle.yaml"
},
```

#### Goland (Jetbrains IDEs)

Use this method if you want to apply the schema to all YAML files in your project without modifying them. Open the IDE settings and navigate to `Languages & Frameworks` -> `Schemas and DTDs` -> `JSON Schema Mappings` and add a new schema using the "+" icon as shown below:

![Goland Schema Mapping](.images/goland-json-schema.png)

Don't forget to set the file path pattern for the JSON schema to apply to.

0 comments on commit a696ffc

Please sign in to comment.