# spell-check

Source: https://apigenie.pl/docs/linter/asyncapi/rules/spell-check

This rule checks the spelling of the texts written for humans: titles, summaries and
descriptions.

## Rule Details

The rule reports every misspelled word, with up to three suggested corrections, for example
`Misspelled word 'Recieve' in summary (did you mean 'Receive', 'Relieve', 'Reverie'?)`.
The issue points at the object whose text contains the word. The rule checks:

- the title and description of the info object,
- the title, summary and description of servers, channels, operations, operation traits,
  messages and message traits,
- the summary and description of message examples,
- the title and description of schemas,
- the description of server variables, parameters, operation reply addresses, correlation
  IDs, tags, external documentation and security schemes.

Descriptions are CommonMark: the rule checks their prose, and skips code spans, code blocks,
raw HTML and link destinations. Titles and summaries are plain text, in which `backticked`
spans are skipped, too. The rule also skips the tokens which are not plain words:

- URLs, e-mail addresses, paths, and file and domain names (`asyncapi.yaml`, `example.com`),
- identifiers: `snake_case`, `camelCase` and names with inner capitals (`AsyncAPI`, `PetStore`),
- acronyms, also in the plural (`MQTT`, `APIs`, `ID's`),
- tokens with digits (`v2`, `401`) and single letters.

The spell checker is a C++ port of [Hunspell](https://hunspell.github.io). By default it uses
the built-in English (US) dictionary from [SCOWL](http://wordlist.aspell.net) (as shipped with
LibreOffice), extended with words common in API descriptions, such as `webhook`, `endpoint`,
`namespace`, `nullable` and `json`. Any Hunspell dictionary can be used instead.

The rule is part of the `strict` and `all` rulesets.

## Configuration

This rule accepts an object with the following options:

- `words`: extra words to accept, for example product names. A word is accepted as given,
  capitalized and in capitals: `petstore` accepts `petstore`, `Petstore` and `PETSTORE`.
- `dictionary` and `affix`: paths of a Hunspell dictionary (`.dic`) and its affix file
  (`.aff`) to use instead of the built-in dictionary. They go together. Dictionaries in UTF-8,
  ISO-8859-1, ISO-8859-2 and ISO-8859-15 are supported.
- `suggestions`: how many corrections to suggest for a word, from 0 to 10 (default 3).
  Suggestions are the costly part of the rule; on a very large document with many unknown
  words, `0` makes it about ten times faster.

**Configuration Example**

```yaml
version: "1.0"
commands:
  lint:
    asyncapi:
      rules:
        spell-check:
          - warning
          - words: [petstore]
            dictionary: path/to/en_GB.dic
            affix: path/to/en_GB.aff
```

## Examples

**Good**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
channels:
  petAdopted:
    address: pets.adopted
operations:
  onPetAdopted:
    action: receive
    channel:
      $ref: "#/channels/petAdopted"
    summary: Receive adoption events
    description: Updates the shelter inventory when a pet is adopted.
```

**Bad**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
channels:
  petAdopted:
    address: pets.adopted
operations:
  onPetAdopted:
    action: receive
    channel:
      $ref: "#/channels/petAdopted"
    summary: Recieve adoption events
    description: Updates the shelter inventroy when a pet is adopted.
```

## When Not to Use It

You may disable this rule if your documentation is written in a language you have no
dictionary for. To silence it for a single object and its children, add
`x-lint-disable: [spell-check]` to the object.

## Compatibility

This rule is compatible with AsyncAPI 3.x documents. AsyncAPI 2.x documents are rejected by
the reader and are not linted.
