-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
conversion: conversion for file upload from v2 to v3 and vice versa #233
Conversation
2482842
to
2b4fe64
Compare
This change enables converting spec for file upload with POST from v2 to v3 and vice versa according to https://swagger.io/docs/specification/2-0/file-upload/ specification. Added support for `multipart/form-data`. Added `in: formData` case for file upload. Updated unit tests related sections.
2b4fe64
to
722b5c0
Compare
Hi @fenollp, Can you review this please? |
Great work! Thanks! |
Thank you for quick review :) |
@@ -121,6 +121,51 @@ func ToV3PathItem(swagger *openapi2.Swagger, pathItem *openapi2.PathItem) (*open | |||
return result, nil | |||
} | |||
|
|||
func ToV3RequestBodyFormData(parameters []*openapi2.Parameter) *openapi3.RequestBodyRef { | |||
if len(parameters) == 0 || parameters[0].In != "formData" { |
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.
Just a quick question, this logic implies that any formData
parameters will only be converted if the very first parameter is a formData
. This means that if the formData
parameter is second in the list it'll not be converted?
Also, the logic below implies that if there was any formData
parameters that any other parameters will be ignored? (https://github.com/getkin/kin-openapi/pull/233/files#diff-29b4895fc45bb3c5db76a7a9635a745eR186-R200)
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.
Indeed it looks like the spec does not enforce this logic. We need a PR that processes the other parameters as well.
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.
I am working on that. I totally omited the fact that other parameters are possible too, since https://swagger.io/docs/specification/2-0/file-upload/ examples not use any and my use-case didn't need any of them.
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.
Addressed in #239
This change enables converting spec for file upload with POST from v2 to v3 and vice versa
according to https://swagger.io/docs/specification/2-0/file-upload/ specification.
Added support for
multipart/form-data
.Added
in: formData
case for file upload.Updated unit tests related sections.