# schema-no-additional-properties

Source: https://api-genie.dev/docs/linter/asyncapi/rules/schema-no-additional-properties

A rule of the AsyncAPI linter, which reads AsyncAPI 3 documents; the reader rejects AsyncAPI 2 documents. 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**.

```yaml
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**.

```yaml
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`.
