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

conversion: conversion for file upload from v2 to v3 and vice versa #233

Merged
merged 1 commit into from
Jul 15, 2020

Conversation

gitforbit
Copy link
Contributor

@gitforbit gitforbit commented Jul 10, 2020

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.

@gitforbit gitforbit force-pushed the feat/file-upload branch 3 times, most recently from 2482842 to 2b4fe64 Compare July 11, 2020 22:06
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.
@gitforbit
Copy link
Contributor Author

Hi @fenollp,

Can you review this please?

@fenollp fenollp merged commit 100b968 into getkin:master Jul 15, 2020
@fenollp
Copy link
Collaborator

fenollp commented Jul 15, 2020

Great work! Thanks!

@gitforbit
Copy link
Contributor Author

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" {

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)

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #239

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.

3 participants