Skip to content
Merged
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
5 changes: 5 additions & 0 deletions docs-vs-code.sidebars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
- group: Usage
page: docs/vscode/using-redocly-vscode.md
items:
- label: Type hints
page: docs/vscode/type-hints.md
- label: Cursor context
page: docs/vscode/cursor-context.md
- label: Type hints vs Cursor context
page: docs/vscode/type-hints-vs-cursor-context.md
- label: Live documentation preview
page: docs/vscode/live-preview.md

48 changes: 48 additions & 0 deletions docs/vscode/type-hints-vs-cursor-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Type hints vs Cursor context

The Redocly OpenAPI VS Code extension now includes [Type hints](./type-hints.md), a lightweight alternative to [Cursor context](./cursor-context.md) for identifying node types.
With type hints you can find the `subject` and `property` values you need for [configurable rules](../cli/rules/configurable-rules#configurable-rules) by hovering over any node in your API description (OpenAPI, AsyncAPI, Arazzo, and others).

## Example: enforcing snake_case operation IDs

Suppose you need to change all operation IDs to use snake_case instead of camelCase.
To avoid missing any operation, let's create a configurable linting rule that checks every operation ID in the OpenAPI document.

When writing your rule, you need to target a specific [node](../../learn/openapi/openapi-visual-reference/openapi-node-types) with the `subject` and `property` to which the rule applies.
To find these values, you can either use Cursor context or Type hints.

### Use [Type hints](./type-hints.md)

To use [Type hints](./type-hints.md) to find the values of `subject` and `property`:

1. Hover over `operationId`.
1. Read `subject` and `property` directly from the tooltip.

![type-hints-tooltip](../../static/images/vscode/openapi-vscode-type-hints.png)

This approach requires fewer steps and keeps you inside the immediate context of your work, without affecting your focus.

### Use Cursor context

To use [Cursor context](./cursor-context.md) to find the values of `subject` and `property`:

1. Place your cursor on `operationId`.
1. Open the Cursor context panel.
1. Find `subject` and `property` in the panel.

![cursor-context-panel](../../static/images/vscode/openapi-vscode-cursor-context-migration.png)

### Rule configuration

```yaml
extends:
- recommended
rules:
struct: error
rule/id-casing:
subject:
type: Operation
property: operationId
assertions:
casing: snake_case
```
21 changes: 21 additions & 0 deletions docs/vscode/type-hints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Type hints

Type hints is a hover feature that helps you identify the correct [node types](../../learn/openapi/openapi-visual-reference/openapi-node-types) used in [configurable rules](../cli/rules/configurable-rules#configurable-rules) and [custom plugins](../cli/custom-plugins#custom-plugins) for writing rules or decorators.

When you hover over a node in your API description, a tooltip displays the node type, a short description, and a link to the corresponding documentation section.

## Type hints example

![type-hints](../../static/images/vscode/openapi-vscode-type-hints.png)

## Type hints structure

```md
type [subject.type] › property [subject.property]

[Documentation link when available]

paths › [node tree path]

[description]
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading