required-fields-defined
This is an advisory schema rule that checks whether fields listed in required are explicitly declared in properties.
While OpenAPI 3.1 and JSON Schema allow more flexible object modeling, explicitly declaring required fields usually improves schema readability, generated types, and downstream tooling behavior.
Why did this violation appear?
A schema lists one or more field names under required, but vacuum could not find a matching property declaration in the schema’s properties map or in composed schemas.
What is this rule checking for?
The rule looks for schemas that:
- declare one or more required fields
- behave like object schemas
- do not explicitly declare a matching property for one or more required field names
The check follows composed schemas such as allOf, oneOf, and anyOf when looking for matching property declarations.
Bad example
components:
schemas:
JobStatus:
type: object
required:
- status
properties:
id:
type: string
Good Example
components:
schemas:
JobStatus:
type: object
required:
- status
properties:
status:
type: string
Good Example Using Composition
components:
schemas:
BaseJob:
type: object
properties:
status:
type: string
JobStatus:
allOf:
- $ref: '#/components/schemas/BaseJob'
- type: object
required:
- status
How do I fix this violation?
Declare each required field explicitly in properties, or move the required declaration so it lines up with the schema composition that defines the field.
If you intentionally rely on looser JSON Schema behavior and do not want this advisory check, leave the rule disabled.
