# license-defined

Source: https://apigenie.pl/docs/linter/openapi/rules/license-defined

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. Since 0.0.1. In the rulesets: Strict at error, All at error.

This rule checks that `info.license` is present, with a `name` and a `url` or an SPDX
`identifier`.

## Rule details

The license says on which terms the API and its description may be used, and a client that cannot
find it has to ask. The OpenAPI specification makes the whole object optional.

The rule reports `License object is missing`, `License name is empty`,
`Both the license URL and identifier are missing or empty` and
`License identifier is not a valid SPDX identifier`. Turn it off for APIs that never leave the
team.

## Examples

**Good**. A name and a link to the text.

```yaml
openapi: 3.1.0
info:
  title: Inventory
  version: 1.0.0
  license:
    name: Apache 2.0
    url: https://your-company.com/api/LICENSE
paths: {}
```

**Good**. A name and an SPDX identifier (OpenAPI 3.1 and later).

```yaml
openapi: 3.1.0
info:
  title: Inventory
  version: 1.0.0
  license:
    name: Apache 2.0
    identifier: Apache-2.0
paths: {}
```

**Bad**. No license.

```yaml
openapi: 3.1.0
info:
  title: Inventory
  version: 1.0.0
paths: {}
```
