schema-no-additional-properties
Since 0.9.0 · fixed by --fix · In the rulesets: Recommended at error, Strict at error, All at error
This rule ensures that object schemas explicitly disallow additional properties.
Rule details
By default, JSON Schema allows objects to contain properties that are not
listed in properties. Messages containing unexpected properties are then
considered valid, which hides typos and makes it easy to leak data that was
never meant to be published.
The schema-no-additional-properties rule reports
Object schema does not disable additional properties for every schema of
type object that does not have additionalProperties: false.
Turn the rule off if your messages are designed to be extensible, or if consumers are expected to ignore unknown properties.
Examples
Good.
asyncapi: 3.0.0
info:
title: User Events
version: 1.0.0
components:
schemas:
UserSignedUp:
type: object
properties:
user_id:
type: string
additionalProperties: false
Bad.
asyncapi: 3.0.0
info:
title: User Events
version: 1.0.0
components:
schemas:
UserSignedUp:
type: object
properties:
user_id:
type: string
Automatic fixes
--fix sets additionalProperties: false on
every reported schema, replacing any other value of additionalProperties.
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:
schema-no-additional-properties: off