Skip to main content

additional-properties-false

Reports object schemas that explicitly set additionalProperties: true.

AttributeValue
CategorySchema
MaturityGold
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterOff
LenientWarning
RecommendedWarning
StrictWarning
CompleteError

Intent​

Closed object schemas make payload fields explicit. Consumers can validate unknown fields consistently, while API owners can evolve the contract deliberately.

Flags​

This rule reports a schema only when both conditions hold:

  • resolved schema type is object;
  • additionalProperties is the Boolean value true.

Does not flag​

  • additionalProperties: false.
  • An omitted additionalProperties field.
  • A schema-valued additionalProperties definition.
  • Non-object schemas.

The rule therefore catches explicit open-object declarations; it does not require every object to declare additionalProperties: false.

See it fail​

openapi: 3.0.3
info:
title: Payments API
version: 1.0.0
paths: {}
components:
schemas:
Payment:
type: object
additionalProperties: true

Specmatic reports:

Object schemas with `additionalProperties` should set it to false.

Fix it​

Close the object and define supported fields:

components:
schemas:
Payment:
type: object
additionalProperties: false
properties:
id:
type: string

Configure​

specmatic-linter.yaml
profiles:
default:
rules:
extends:
- recommended
override:
additional-properties-false: error

Nearby rules​

  • no-unconstrained-additional-properties
  • invalid-additional-properties-usage
  • no-schema-type-mismatch