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

Force request body to be an schema object #922

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

numbata
Copy link
Contributor

@numbata numbata commented Apr 11, 2024

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.

@numbata numbata marked this pull request as ready for review April 11, 2024 22:33
@numbata
Copy link
Contributor Author

numbata commented Apr 16, 2024

@LeFnord Can I ask you to take a look at the PR?

Copy link
Member

@LeFnord LeFnord left a 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

@numbata
Copy link
Contributor Author

numbata commented Apr 18, 2024

@LeFnord any suggestions what to write in CHANGELOG? :)

@LeFnord
Copy link
Member

LeFnord commented Apr 18, 2024

@numbata
Copy link
Contributor Author

numbata commented Apr 19, 2024

@LeFnord CHANGELOG and UPGRADING files updated: a812d0c.

@LeFnord
Copy link
Member

LeFnord commented Apr 22, 2024

thanks @numbata

@LeFnord LeFnord merged commit e2b50b3 into ruby-grape:master Apr 22, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants