Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: global setting to set additionalProperties as false #644

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MichaelAlexanderBanuelos
Copy link

@MichaelAlexanderBanuelos MichaelAlexanderBanuelos commented Jun 1, 2023

Problem

Currently, Rswag does not provide a global setting to control the additionalProperties behavior in OpenAPI schemas. This means that additionalProperties is set to true 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 set additionalProperties: 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:

  • OAS2
  • OAS3
  • OAS3.1

Related Issues

N/A

Checklist

  • Added tests
  • Changelog updated
  • Added documentation to README.md
  • Added example of using the enhancement into test-app

Steps to Test or Reproduce

  1. Configure the new global setting for disallow_additional_properties: true.
  2. Run the swagger tests and verify that responses with undocumented keys fail the test.

Copy link

stale bot commented May 31, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If the issue is still relevant to you, please leave a comment stating so to keep the issue from being closed. Thank you for your contributions.

@stale stale bot added the wontfix label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants