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

multipart/form-data in V2 is not properly handled #747

Closed
justinyoo opened this issue Feb 17, 2022 · 2 comments · Fixed by #987
Closed

multipart/form-data in V2 is not properly handled #747

justinyoo opened this issue Feb 17, 2022 · 2 comments · Fixed by #987
Assignees
Labels
priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days type:bug A broken experience
Milestone

Comments

@justinyoo
Copy link

Hi, Team.

I found that there had been an issue #509 and fix #511 with regards to the file upload through the multipart/form-data content type. However, when I checked the source code, it only partially covers the cases.

  1. According to the OpenAPI v3.0.1 spec, file input/output can be the schema type/format of string/binary or string/base64. However, the codebase only looks after the string/binary pair.

    if (paramSchema.Type == "string" && paramSchema.Format == "binary") {
    paramSchema.Type = "file";
    paramSchema.Format = null;
    }

  2. According to the 3.0.1 spec, it's valid to have schema reference (the $ref value) under the requestBody/content/<media-type>/schema object instead of the properties object. However, the current codebase only looks after the properties object.

    foreach (var property in RequestBody.Content.First().Value.Schema.Properties)

Therefore, these two issues need to be resolved for proper V3 ➡️ V2 conversion. The Azure Functions OpenAPI extension has addressed this issue, which relies on this OpenAPI.NET package.

@darrelmiller
Copy link
Member

Thanks for reporting this. We will investigate.

@darrelmiller darrelmiller added the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Feb 22, 2022
@darrelmiller darrelmiller added priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days status:waiting-for-triage An issue that is yet to be reviewed or assigned and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Mar 1, 2022
@darrelmiller darrelmiller added this to the 1.4 milestone Mar 29, 2022
@darrelmiller darrelmiller removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Jul 5, 2022
@MaggieKimani1 MaggieKimani1 removed their assignment Aug 2, 2022
@darrelmiller
Copy link
Member

The first option can be resolved with this update.

 if (paramSchema.Type == "string" && (paramSchema.Format == "binary" || paramSchema.Format == "base64") ) { 
     paramSchema.Type = "file"; 
     paramSchema.Format = null; 
 } 

The second item shouldn't actually be an issue as $ref should get resolved during reference resolution after reading the file in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days type:bug A broken experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants