diff --git a/docs/_data/main-nav.yaml b/docs/_data/main-nav.yaml index 21d18e2..a6ffa6f 100644 --- a/docs/_data/main-nav.yaml +++ b/docs/_data/main-nav.yaml @@ -181,6 +181,8 @@ toc: url: /inso-cli/cli-command-reference/inso-script - title: OpenAPI Spec Reference url: /inso-cli/cli-command-reference/OAS-spec.yml + - title: Using Custom Linting with Inso CLI + url: /inso-cli/cli-command-reference/inso-custom-linting - title: Configuration url: /inso-cli/configuration - title: Inso CLI on Docker diff --git a/docs/assets/images/custom-ruleset-example.jpg b/docs/assets/images/custom-ruleset-example.jpg new file mode 100644 index 0000000..196b44a Binary files /dev/null and b/docs/assets/images/custom-ruleset-example.jpg differ diff --git a/docs/assets/images/git-commit-example.jpg b/docs/assets/images/git-commit-example.jpg new file mode 100644 index 0000000..a0bae96 Binary files /dev/null and b/docs/assets/images/git-commit-example.jpg differ diff --git a/docs/inso-cli/cli-command-reference/inso-custom-linting.md b/docs/inso-cli/cli-command-reference/inso-custom-linting.md new file mode 100644 index 0000000..963727e --- /dev/null +++ b/docs/inso-cli/cli-command-reference/inso-custom-linting.md @@ -0,0 +1,32 @@ +--- +layout: article-detail +title: Using Custom Linting with Inso CLI +category: "Using Custom Linting with Inso CLI" +category-url: inso-custom-linting +--- + +This tutorial will guide you through the process of implementing custom linting for your OpenAPI Specification (OAS) files using Inso CLI and Insomnia. Custom linting allows you to apply specific rules that suit your project's requirements, ensuring your API specifications maintain high quality and consistency. + +### Step 1: Create Your Custom Spectral Ruleset File + +First, you need to create a Spectral ruleset file. This file can be in YAML, YML, JSON, or JS format. For example, create a file named `.spectral.yml` and define your custom rules in it. + +### Step 2: Place the Ruleset File in the Correct Directory + +Place your `.spectral.(yaml|yml|json|js)` file in the same directory as your OAS file (`oas.yaml`). + +### Step 3: Run Inso CLI Lint Command + +Open your terminal and navigate to the directory containing your OAS file and the custom Spectral ruleset file. Run the following command: + +```bash +inso lint spec ./oas.yaml +``` + +The Inso CLI will automatically detect the `.spectral` file in the directory and use it to lint your `oas.yaml` file according to the custom rules you've defined. + +### Step 4: Review the Output + +Inspect the output in your terminal. It will display any issues found based on your custom linting rules. Make necessary adjustments to your OAS file based on these results. + +> For custom linting on Insomnia refer to [this document](https://docs.insomnia.rest/insomnia/linting#custom-linting). diff --git a/docs/inso-cli/cli-command-reference/inso-lint-spec.md b/docs/inso-cli/cli-command-reference/inso-lint-spec.md index c7281d3..4e78db3 100644 --- a/docs/inso-cli/cli-command-reference/inso-lint-spec.md +++ b/docs/inso-cli/cli-command-reference/inso-lint-spec.md @@ -21,6 +21,8 @@ Lint the given specification, the user will be prompted to select a specificatio At the moment Inso CLI uses Spectral's default `oas` Ruleset Definition. For more information refer to the [OpenAPI ruleset reference documentation](https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md). +> For custom linting, refer to the [Custom Linting](custom-linting) document. + ## Global Flags {:.table .table-striped} @@ -30,7 +32,6 @@ Option | Alias | Description `--workingDir ` || Specify a working directory. `--src ` || Specify the V4 export file or the Insomnia app data directory. You can use this option to set a Git data directory. If not specified, `inso-cli` looks for an `.insomnia` folder in the working directory by default. - ## Examples The following commands work when running in the example [git-repo](https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo) directory. diff --git a/docs/insomnia/git-sync.md b/docs/insomnia/git-sync.md index 9d3a80d..b374a93 100644 --- a/docs/insomnia/git-sync.md +++ b/docs/insomnia/git-sync.md @@ -106,7 +106,7 @@ Local branches can be created from the branch management dialog. This dialog pre Commit your changes via the branch dropdown menu. You'll be prompted to add a descriptive message as your commit message. -![Click the branch dropdown menu and select commit](/assets/images/commit-git-sync.png) +![Click the branch dropdown menu and select commit](../assets/images/git-commit-example.jpg) ## Push Changes diff --git a/docs/insomnia/linting.md b/docs/insomnia/linting.md index 6f69901..dc08d61 100644 --- a/docs/insomnia/linting.md +++ b/docs/insomnia/linting.md @@ -12,26 +12,20 @@ The Linter Panel aggregates all errors and warnings from the spec into a central ![The linting errors appear in a box below the editor.](/assets/images/linting-errors.png) _Errors are displayed next to the applicable code line, and in the Linter Panel below the editor._ - ## Custom Linting + To use a custom linting ruleset in the Insomnia Design Editor, add the spectral .yaml file to the root of the collection git repository. It should be at the same level as the .insomnia folder. ![Instructions for Adding Custom Rule Set](/assets/images/custom-linting.png) - -Once the custom ruleset file is added to the repo, commit it to the synced repo and make sure your Insomnia Editor is on the latest changes and on the branch that contains the file. +Once the custom ruleset file is added to the repo, commit it to the synced repo and make sure your Insomnia Editor is on the latest changes and on the branch that contains the file. To see the ruleset file begin to be used, you can restart the Insomnia App, or exit out of the workspace and enter again. Now the Insomnia Design editor should use the custom ruleset for linting. ![Example of Custom Linting Violation](/assets/images/custom-linting-violation.png) - ### Adding Remote Link or NPM Modules for Custom Linting + In Insomnia, we support spectral extensions of custom linting rules, including using remote urls or NPM modules to extend linting definitions. In order to extend the .spectral.yaml custom linting definition, please follow [Spectral's Documentation](https://docs.stoplight.io/docs/spectral/83527ef2dd8c0-extending-rulesets) - - - - -