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
Improving generation of OAS3.0 requestBody
from parameter
s
#723
Open
stevegeek
wants to merge
10
commits into
rswag:v3
Choose a base branch
from
stevegeek:v3_requestbody_improvements
base: v3
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…mat: :binary` for OAS3
romanblanco
reviewed
Jan 29, 2024
# There can only be 1 body parameter in Swagger 2.0, so while in OAS3 we interpret | ||
# body parameters as formData, only consider the first body we encounter. | ||
schema_param = parameters.find { |p| p[:schema] if p[:in] == :body } | ||
parse_body_parameter(endpoint, schema_param, mime_list) if schema_param |
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.
@stevegeek, the Swagger 2.0 support is being dropped in this branch.
It seems to me that the parse_body_parameter
function can be dropped.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 / Solution
The handling of path
parameter
s does not currently generate OAS3.0requestBody
correctly in some cases. This PR proposes a refactoring and updates toSwaggerFormatter
to improve translation of the DSL defined parameters.It takes the approach that any parameter defined as
in: :body
is handled differently to parameters that arein: :formData
. A request can only have a singlebody
parameter but can have multipleformData
parameters.It also adds support for translating a
:file
parameter to the new OAS3.0 schema and some tests for the httpbearer
security schema.I started this as I wanted to specify parameter for multipart requestBody (including file upload with multiple possible content types) and ended up making these changes so far.
This concerns this parts of the OpenAPI Specification:
Note that file upload definitions improved in OAS3.1 but this PR does not yet attempt to support that
The changes I made are compatible with:
Checklist
Thanks so much for all the work on
rswag
over the years, its great!