Linter rulesSwagger 2.0license-defined
license-defined
Since 0.9.0
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.
Configuration
None.
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: {}
When Not to Use It
You may skip licensing information for team-level APIs.
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
license-defined rules.