feature: global setting to set additionalProperties as false #644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, Rswag does not provide a global setting to control the
additionalProperties
behavior in OpenAPI schemas. This means thatadditionalProperties
is set totrue
by default, allowing any additional properties to be added to objects without validation. This can lead to unexpected data inconsistencies and potential security vulnerabilities.This provides a solution for issues like #402
Solution
This pull request introduces a new global setting
disallow_additional_properties
in Rswag that allows users to setadditionalProperties: false
on all schemas by default, unless they have already been defined. This setting provides better control and enforces stricter validation on object properties throughout the API documentation.Alternatively if we decide to not use this change or something similar, folks can still manually set
additionalProperties: false
but when working in a larger codebase its easy to forget these things.This concerns these parts of the OpenAPI Specification:
The changes I made are compatible with:
Related Issues
N/A
Checklist
Steps to Test or Reproduce
disallow_additional_properties: true
.