license-defined

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.

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.

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

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.asyncapi has the details.

commands:
  lint:
    asyncapi:
      rules:
        license-defined: off

Related rules

Was this helpful?