Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/_data/products/insomnia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ releases:
version: "12.5.0"
- release: "12.6"
version: "12.6.0"
latest: true
- release: "13.0"
version: "13.0.0"
latest: true
15 changes: 15 additions & 0 deletions app/_data/schemas/frontmatter/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,23 @@
"tags": {
"type": "array",
"items": { "$ref": "schema:tags" }
},
"tier": {
"type": "string"
},
"tiers": {
"type": "object",
"patternProperties": {
"^[a-z][a-z0-9-]*$": {
"type": "string"
}
},
"additionalProperties": false
}
},
"not": {
"required": ["tier", "tiers"]
},
"if": {
"properties": {
"products": {
Expand Down
95 changes: 70 additions & 25 deletions app/_how-tos/insomnia/add-custom-linting-rules.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
---
title: Add custom linting rules in Insomnia
title: "Add custom linting rules in {{ site.data.products.insomnia.name }}"
permalink: /how-to/add-custom-linting-rules/

content_type: how_to
description: Learn how to add custom linting rules to your APIs in Insomnia.
description: Learn how to add custom linting rules to your APIs in Insomnia .
no_wrap: true

products:
- insomnia
- insomnia

min_version:
insomnia: "13.0"
tags:
- insomnia-documents
- linting

related_resources:
- text: Design APIs with Insomnia
- text: "Design APIs with {{ site.data.products.insomnia.name }}"
url: /insomnia/design/


tldr:
q: How do I customize linting in Insomnia?
a: In your Git repository, add a `.spectral.yaml` file containing your custom ruleset at the same directory as the OAS file to lint.
tldr:
q: How do I customize linting in {{ site.data.products.insomnia.name }} ?
a: In your {{ site.data.products.insomnia.name }} document, click the upload icon for the **Default OAS Ruleset** and add a Spectral ruleset YAML file with your custom ruleset.

prereqs:
inline:
- title: Create a design document
include_content: prereqs/design-document
icon_url: /assets/icons/file.svg
- title: Synchronize with Git
include_content: prereqs/git-sync
icon_url: /assets/icons/git.svg

faqs:
- q: How can I use custom linting with Inso CLI?
a: |
Create your `.spectral.yaml` file in the same directory as the OAS file to lint, then run the [`inso lint spec`](/inso-cli/reference/lint_spec/) command.
Create a [Spectral ruleset](https://docs.stoplight.io/docs/spectral/e5b9616d6d50c-rulesets) in YAML format, and upload it to an OAS file document in Insomnia by clicking the upload icon for the **Default OAS Ruleset**.

---

## Create add the file ruleset

In the Git repository connected to your document, create a `.spectral.yaml` at the same directory as the OAS file to lint.
{{ site.data.products.insomnia.name }} provides a default linting ruleset. Override it to add your custom linting rules by following these steps:

## Define the rules

The custom ruleset overrides the default one. If you want to create a completely new ruleset, you can simply add your rules in the file using the [Spectral](https://docs.stoplight.io/docs/spectral/e5b9616d6d50c-rulesets) syntax. If you want to extend an existing ruleset, specify the ruleset with the `extend` property in `.spectral.yaml`.
The custom ruleset overrides the default one. To create a new ruleset, add your rules in the file using the [Spectral](https://docs.stoplight.io/docs/spectral/e5b9616d6d50c-rulesets) syntax. If you want to extend an existing ruleset, specify the ruleset with the `extends` property.

{:.info}
> Available Spectral top level properties in {{ site.data.products.insomnia.name }} are `rules` and `extends`. Custom functions are not permitted. However, {{ site.data.products.insomnia.name }} provides support for [Spectral built-in core functions](https://docs.stoplight.io/docs/spectral/cb95cf0d26b83-core-functions).

For example, if you want to extend the default [Spectral OpenAPI](https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules) ruleset to add a warning when tags don't have a description, you can add the following content to `.spectral.yaml`:
For example, to extend the default [Spectral OpenAPI](https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules) ruleset to add a warning when tags don't have a description, add the following content to your ruleset file:

```yaml
extends: spectral:oas
Expand All @@ -59,20 +59,65 @@ rules:
function: truthy
```

## Synchronize the changes
## Upload the ruleset file

Commit and push the file on the repository, then pull the changes in Insomnia.
1. In the {{ site.data.products.insomnia.name }} app, navigate to a document with the OAS file you want to lint.
2. Click the upload icon for **Default OAS Ruleset** at the bottom of the pane.

{:.info}
> This will place the `.spectral.yaml` file in the local working directory. You will not see the file in the Insomnia UI but the linting rules will be applied to the associated OAS file.
This places the ruleset file in the local working directory. {{ site.data.products.insomnia.name }} renames this custom ruleset as `.spectral.yaml`.

You can view the content of the file by clicking `Custom Ruleset` in {{ site.data.products.insomnia.name }}. If you want to make changes to the file, edit it locally.

## Validate

Close and reopen the document to apply the changes. In this example, you can validate by creating a new tag without a description:
In this example, you can confirm the rule triggers by removing the description for the `GET /flights` endpoint. This will be flagged since the ruleset doesn't allow tags without a description:

```yaml
tags:
- name: flight-data
"/flights":
get:
summary: Get KongAir planned flights
tags:
- flight-data
```

This causes a new warning to appear:
![Missing tag description warning](/assets/images/insomnia/custom-linting-warning.png)

```
tag-description Tags must have a description.
```

## Override the rules {% new_in 13 %}

Override the linting rules and use another ruleset, by using either Inso CLI or `.spectral.yaml`:

{% navtabs "custom linting" %}
{% navtab "Inso CLI" %}

Use the [Inso CLI(/inso-cli/reference/lint_spec/) with the `--ruleset` or `-r` flag and the path to your custom ruleset. Run `inso lint spec --ruleset <path-to-custom-ruleset>`. This overrides the default OpenAPI specifications (OAS) ruleset in {{ site.data.products.insomnia.name }} , and any ruleset in the API Spec folder.

If the `--ruleset` flag isn't specified, {{ site.data.products.insomnia.name }} uses one of the following, in order:

- The ruleset defined in `.spectral.yaml`, if it exists.
- The default OAS ruleset.

{% endnavtab %}
{% navtab "Use `extends` in `.spectral.yaml`" %}

Make {{ site.data.products.insomnia.name }} point at another ruleset in `.spectral.yaml` by using the `extends` property. For example:

```yaml
extends:
- spectral:oas
- ./rules/my-rules.yaml
```

If you reference a remote file (one hosted outside of your project in {{ site.data.products.insomnia.name }}), {{ site.data.products.insomnia.name }} fetches its content only when you upload the custom ruleset. If the remote file later changes, {{ site.data.products.insomnia.name }}:

- Doesn't track those changes in commits, because the file lives outside the project.
- Doesn't fetch them automatically for security reasons. Instead, you can refresh manually using the button next to the ruleset option.

{% endnavtab %}
{% endnavtabs %}

{:.warning}
> Make sure users in your team are running at least {{ site.data.products.insomnia.name }} `13.0` to avoid compatibility issues with this feature.
5 changes: 2 additions & 3 deletions app/_includes/components/prereqs.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@
{% endif %}

{% if prereqs.entities? %}
{% if product == 'operator' %}{% assign product='kic' %}{% endif %}
<div class="flex flex-col gap-1.5 border-b border-primary accordion-item last:border-b-0">
{% assign prereq_path = "prereqs/entities/" | append: product | append: ".md" %}
<div class="flex flex-col gap-1.5 border-b border-primary/5 accordion-item last:border-b-0">
{% assign prereq_path = "prereqs/entities/" | append: prereqs.entities_product | append: ".md" %}
{% include {{ prereq_path }} data=prereqs.data %}
</div>
{% endif %}
Expand Down
3 changes: 1 addition & 2 deletions app/_includes/components/prereqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
{% include prereqs/operator/konnect_network.md config=prereqs.operator.konnect %}
{%- endif -%}
{%- if prereqs.entities? -%}
{%- if product == 'operator' %}{% assign product='kic' %}{% endif %}
{%- assign prereq_path = "prereqs/entities/" | append: product | append: ".md" -%}
{%- assign prereq_path = "prereqs/entities/" | append: prereqs.entities_product | append: ".md" -%}
{% include {{ prereq_path }} data=prereqs.data %}
{%- endif -%}
{%- for prereq in prereqs.inline_without_position %}
Expand Down
3 changes: 3 additions & 0 deletions app/_includes/landing_pages/header.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<div class="flex gap-2 items-center">
{% if page.tier %}
{% include tier.html products=page.products tier=page.tier %}
{% endif %}
{% if page.tiers %}
{% include tier.html products=page.products tiers=page.tiers %}
{% endif %}
{%- if page.beta == true or page.tech_preview == true -%}
{%- include_cached badges/stage.html beta=page.beta tech_preview=page.tech_preview -%}
Expand Down
6 changes: 5 additions & 1 deletion app/_includes/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{%- if layout.uses == false and page.beta == true -%}{%- assign show_badges = true -%}{%- endif -%}
{%- if layout.uses == false and page.tech_preview == true -%}{%- assign show_badges = true -%}{%- endif -%}
{%- if layout.tier_inline == true and page.tier -%}{%- assign show_badges = true -%}{%- endif -%}
{%- if layout.tier_inline == true and page.tiers -%}{%- assign show_badges = true -%}{%- endif -%}
{%- if page.premium_partner or page.third_party -%}{%- assign show_badges = true -%}{%- endif %}
<main {% if page.topology_switcher %}data-topology-switcher="{{ page.topology_switcher }}" {% endif %}id="main" class="flex flex-col pb-12 gap-12 w-full {{ page.content_type | slugify }} {{include.class}}">
<div class="flex flex-col gap-3">
Expand All @@ -17,6 +18,9 @@ <h1 id="{{page.title | slugify}}" class="link-anchor">{{ page.title | liquify }}
{% if layout.tier_inline == true and page.tier %}
{% include tier.html products=page.products tier=page.tier %}
{% endif %}
{% if layout.tier_inline == true and page.tiers %}
{% include tier.html products=page.products tiers=page.tiers %}
{% endif %}

{% if layout.uses == false %}
{%- if page.beta == true or page.tech_preview == true -%}
Expand All @@ -43,7 +47,7 @@ <h1 id="{{page.title | slugify}}" class="link-anchor">{{ page.title | liquify }}
{% endif %}

{% if layout.uses != false %}
{% include_cached uses.html products=page.products tools=page.tools tier=page.tier beta=page.beta tech_preview=page.tech_preview %}
{% include_cached uses.html products=page.products tools=page.tools tier=page.tier tiers=page.tiers beta=page.beta tech_preview=page.tech_preview %}
{% endif %}

{% ifhascontent nav_header %}
Expand Down
58 changes: 43 additions & 15 deletions app/_includes/tier.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
{% unless page.plugin? %}
{% if include.products and include.products.size > 1 %}
{% raise "tier.html include called with a tier and more than one product." %}
{% if include.tier and include.tiers %}
{% raise "tier.html: page `{{page.url}}` sets both `tier` and `tiers`. Use one or the other." %}
{% endif %}
{% if include.tier and include.products and include.products.size > 1 %}
{% raise "tier.html: page `{{page.url}}` sets `tier` with more than one product. Use `tiers:` to map each product to its tier." %}
{% endif %}
{% endunless %}

{% assign product = include.products.first %}
{% assign tier = site.data.products[product].tiers[include.tier] %}
{% unless tier %}
{%- capture available_tiers -%}
{%- for tier in site.data.products[product].tiers -%}{{tier[0]}}{% unless forloop.last %}, {% endunless %}{%- endfor -%}
{%- endcapture -%}
{% raise "tier.html: invalid tier `{{include.tier}}` for product: `{{product}}`. Available tiers: {{available_tiers}}" %}
{% endunless %}
{% if include.tier %}
{% assign product = include.products.first %}
{% assign tier_data = site.data.products[product].tiers[include.tier] %}
{% unless tier_data %}
{%- capture available_tiers -%}
{%- for t in site.data.products[product].tiers -%}{{t[0]}}{% unless forloop.last %}, {% endunless %}{%- endfor -%}
{%- endcapture -%}
{% raise "tier.html: invalid tier `{{include.tier}}` for product: `{{product}}`. Available tiers: {{available_tiers}}" %}
{% endunless %}

{% if include.url %}
{% include badge.html url=tier_data.url text=tier_data.text css_class=include.tier %}
{% else %}
{% include badge.html text=tier_data.text css_class=include.tier %}
{% endif %}
{% elsif include.tiers %}
{% for pair in include.tiers %}
{% assign tier_product = pair[0] %}
{% assign tier_name = pair[1] %}

{% if include.url %}
{% include badge.html url=tier.url text=tier.text css_class=include.tier %}
{% else %}
{% include badge.html text=tier.text css_class=include.tier %}
{% endif %}
{% unless include.products contains tier_product %}
{% raise "tier.html: product `{{tier_product}}` listed in `tiers` is not present in `products` for page `{{page.url}}`." %}
{% endunless %}

{% assign tier_data = site.data.products[tier_product].tiers[tier_name] %}
{% unless tier_data %}
{%- capture available_tiers -%}
{%- for t in site.data.products[tier_product].tiers -%}{{t[0]}}{% unless forloop.last %}, {% endunless %}{%- endfor -%}
{%- endcapture -%}
{% raise "tier.html: invalid tier `{{tier_name}}` for product: `{{tier_product}}`. Available tiers: {{available_tiers}}" %}
{% endunless %}

{% if include.url %}
{% include badge.html url=tier_data.url text=tier_data.text css_class=tier_name %}
{% else %}
{% include badge.html text=tier_data.text css_class=tier_name %}
{% endif %}
{% endfor %}
{% endif %}
7 changes: 5 additions & 2 deletions app/_includes/uses.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if include.products or include.tools or include.tier or include.beta == true or include.tech_preview == true %}
{% if include.products or include.tools or include.tier or include.tiers or include.beta == true or include.tech_preview == true %}
<div class="flex gap-2 items-center flex-wrap">
{%- if include.beta == true or include.tech_preview == true -%}
{%- include_cached badges/stage.html beta=include.beta tech_preview=include.tech_preview -%}
Expand All @@ -7,8 +7,11 @@
{% if include.tier %}
{% include tier.html products=include.products tier=include.tier %}
{% endif %}
{% if include.tiers %}
{% include tier.html products=include.products tiers=include.tiers %}
{% endif %}

{% if include.tier or include.beta == true or include.tech_preview == true %}
{% if include.tier or include.tiers or include.beta == true or include.tech_preview == true %}
{% if include.products or include.tools %}
<span class="text-sm"> and uses: </span>
{% endif %}
Expand Down
13 changes: 9 additions & 4 deletions app/_plugins/drops/prereqs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ def inline
@inline ||= prereqs.fetch('inline', [])
end

def data
product = @page.data.fetch('products', [])[0]
def entities_product
@entities_product ||= begin
product = prereqs['entities_product'] || @page.data.fetch('products', [])[0]
product = 'kic' if product == 'operator'
product
end
end

# Use KIC rendering for Operator for now
product = 'kic' if product == 'operator'
def data
product = entities_product

yaml = {}
yaml = { '_format_version' => '3.0' } if product == 'gateway'
Expand Down
10 changes: 10 additions & 0 deletions app/_plugins/generators/data/llm_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def frontmatter
'ai_gateway_enterprise' => @page.data['ai_gateway_enterprise'],
'min_version' => @page.data['min_version'],
'tier' => @page.data['tier'],
'tiers' => resolve_tiers(@page.data['tiers']),
'products' => resolve_names(@page.data['products'], 'products'),
'tools' => resolve_names(@page.data['tools'], 'tools'),
'beta' => @page.data['beta']
Expand All @@ -56,6 +57,15 @@ def resolve_names(slugs, data_key)
Array(slugs).map { |slug| @site.data.dig(data_key, slug, 'name') || slug }
end

def resolve_tiers(tiers)
return if tiers.nil? || tiers.empty?

tiers.each_with_object({}) do |(product, tier_name), out|
name = @site.data.dig('products', product, 'name') || product
out[name] = @site.data.dig('products', product, 'tiers', tier_name, 'text') || tier_name
end
end

def plugin_metadata
if @page.data['plugin?'] && @page.data['overview?']
{
Expand Down
25 changes: 25 additions & 0 deletions app/_references/inso-cli/reference/13.0/export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: export
---

## Command Description

Export data from insomnia models

## Syntax

`export [options] [command]`

## Global Flags

- `-v, --version`: output the version number
- `-w, --workingDir <dir>`: set working directory/file: .insomnia folder, *.db.json, export.yaml
- `--verbose`: show additional logs while running the command
- `--ci`: run in CI, disables all prompts, defaults to false
- `--config <path>`: path to configuration file containing above options (.insorc)
- `--printOptions`: print the loaded options

## Subcommands

- [`export spec`](/inso-cli/reference/export_spec/{{page.release}}/): Export an API Specification to a file, identifier can be an API Spec id

Loading
Loading