# license-defined

Source: https://api-genie.dev/docs/linter/asyncapi/rules/license-defined

A rule of the AsyncAPI linter, which reads AsyncAPI 3 documents; the reader rejects AsyncAPI 2 documents. Since 0.9.0. In the rulesets: Strict at error, All at error.

This rule checks whether the licensing information is present in an AsyncAPI
document.

## Rule details

The license says what a consumer may do with the API and with the code generated from its
document; without it, a consumer outside the team has to ask. The rule checks that `info.license`
exists with a `name` and a `url`.

The rule reports:

- `License object is missing` when there is no `info.license` object,
- `License name is empty` when `name` is empty,
- `License URL is missing or empty` when `url` is missing or empty.

Unlike OpenAPI 3.1, AsyncAPI license objects have no SPDX `identifier` field,
so the rule always requires a URL.

Turn the rule off for APIs used only by the team that owns them.

## Examples

**Good**. The document provides a link to its license, thus making it easier
to understand how the API can be used.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
```

**Bad**. The license has a name, but no link to its terms.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
  license:
    name: Proprietary
```
