Skip to content

Commit

Permalink
chore: update custom linting doc [INS-3273] (#182)
Browse files Browse the repository at this point in the history
* chore: update custom linting doc [INS-3273]

* update git commit example img
  • Loading branch information
filfreire authored Nov 17, 2023
1 parent 9c45356 commit 3eceaef
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/_data/main-nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added docs/assets/images/custom-ruleset-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/git-commit-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions docs/inso-cli/cli-command-reference/inso-custom-linting.md
Original file line number Diff line number Diff line change
@@ -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).
3 changes: 2 additions & 1 deletion docs/inso-cli/cli-command-reference/inso-lint-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -30,7 +32,6 @@ Option | Alias | Description
`--workingDir <path>` || Specify a working directory.
`--src <path>` || 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.
Expand Down
2 changes: 1 addition & 1 deletion docs/insomnia/git-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 3 additions & 9 deletions docs/insomnia/linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)





1 comment on commit 3eceaef

@vercel
Copy link

@vercel vercel bot commented on 3eceaef Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

insomnia-docs – ./

insomnia-docs-git-main-green-rs.vercel.app
insomnia-docs-three.vercel.app
insomnia-docs-green-rs.vercel.app

Please sign in to comment.