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 a Swagger 2.0 document.
Rule details
The license-defined rule ensures that the info.license object is defined,
and that both its name and its url are provided. The license specifies the
terms under which the API can be used, and helps consumers of the API to
understand any restrictions that apply.
The rule reports:
License object is missingwhen there is noinfo.licenseobject,License name is emptywhennameis empty,License URL is missing or emptywhenurlis missing or empty.
Swagger 2.0 license objects have no SPDX identifier field (it was added in
OpenAPI 3.1), so the rule always requires a URL.
The OpenAPI and AsyncAPI linters have rules of the same name, license-defined and license-defined.
Turn the rule off for APIs used only by the team that owns them.
Examples
Good. The document links to its license, which makes it easier to understand how the API can be used.
swagger: '2.0'
info:
title: Pet Store
version: 1.0.0
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
paths: {}
Bad. The license has a name, but no link to its terms.
swagger: '2.0'
info:
title: Pet Store
version: 1.0.0
license:
name: Proprietary
paths: {}
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.swagger has the details.
commands:
lint:
swagger:
rules:
license-defined: off