# spell-check

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

This rule checks the spelling of the texts of a Swagger 2.0 document 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'?)`.
When there are no suggestions, the part in parentheses is omitted. The issue points at the
object whose text contains the word. The rule checks:

- the title and description of the info object,
- the summary and description of operations,
- the title and description of schemas,
- the description of parameters, responses (but not response references), headers, security
  definitions, tags and external documentation objects.

Descriptions are Markdown (GFM in Swagger 2.0): 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 (`swagger.yaml`, `example.com`),
- identifiers: `snake_case`, `camelCase` and names with inner capitals (`PetStore`),
- acronyms, also in the plural (`HTTP`, `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:
    swagger:
      rules:
        spell-check:
          - warning
          - words: [petstore]
            dictionary: path/to/en_GB.dic
            affix: path/to/en_GB.aff
```

## Examples

**Good**.

```yaml
swagger: '2.0'
info:
  title: Pet Store
  version: 1.0.0
paths:
  /pets:
    get:
      summary: Receive the list of pets
      description: Returns the pets available for adoption.
      responses:
        '200':
          description: The list of pets.
```

**Bad**.

```yaml
swagger: '2.0'
info:
  title: Pet Store
  version: 1.0.0
paths:
  /pets:
    get:
      summary: Recieve the list of pets
      description: Returns the pets availabel for adoption.
      responses:
        '200':
          description: The list of pets.
```

## 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 Swagger 2.0 documents. OpenAPI 3.x and AsyncAPI documents are
linted by the OpenAPI and AsyncAPI linters, which have their own `spell-check` rules.
