The Spectral truthy function reports a rule violation when its input is false, an empty string, 0, null, or undefined. Applied to $.info with field: description, it checks that an API definition provides info.description. section 3.6
Require info.description
A Spectral rule can set given to $.info, field to description, and function to truthy. Running spectral lint minimal.oas.yaml --ruleset simple.ruleset.yaml reports an error when the description is absent, allowing the rule severity to determine pipeline failure behavior. section 3.6
Listing 3.1 A Spectral rule to check that info.description is present
rules:
info-description-is-required: #1
message: "API definition files must
have info.description defined" #2
severity: error #3
given: $.info #4
then:
field: description #5
function: truthy #6
Inspect the complete rule definition, including its message, error severity, target object, field, and truthy function. section 3.6
