-
Notifications
You must be signed in to change notification settings - Fork 472
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
Force request body to be an schema object #922
Conversation
@LeFnord Can I ask you to take a look at the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah … I checked it out an tested it, works perfectly well, many thanks
please can you add a CHANGELOG entry, then I'll mörge and release it
@LeFnord any suggestions what to write in CHANGELOG? :) |
… hava a look on it → https://github.com/ruby-grape/grape-swagger/blob/master/CHANGELOG.md 😉 |
thanks @numbata |
Motivation
There is an ongoing issue in grape-swagger where array parameters are incorrectly generated as top-level arrays in the Swagger documentation, as described in GitHub issue #666. This misrepresentation leads to API integration issues and confusion, as grape expects arrays to be part of a JSON object in request bodies. The community has resorted to workarounds such as introducing dummy parameters to force the correct structure, which is not ideal for clean and maintainable code.
Solution
This PR addresses the issue by enforcing that all request bodies are defined as schema objects within the Swagger documentation, even if they contain arrays. By modifying how grape-swagger interprets and documents array types, this PR ensures that arrays are always nested within an object schema, aligning Swagger output with grape requirements and common API design practices. The changes eliminate the need for workarounds, sand prevent potential integration issues, making the API documentation clearer and more accurate.