-
Notifications
You must be signed in to change notification settings - Fork 198
Description
Describe the issue
When the OpenAPI doc is rendered through the v3 spec, the multipart/form-data request body is rendered correctly. However, when it's rendered through the v2 spec, the request body is missing.
To Reproduce
Steps to reproduce the behavior:
- Build a function app containing a file upload field in a request body through the
multipart/form-datacontent type. - Run the function app.
- Access the OpenAPI document through
http://localhost:7071/api/openapi/v3.json - Confirm whether it renders correctly.
- Access the OpenAPI document through
http://localhost:7071/api/openapi/v2.json - Confirm whether the request body is missing.
Expected behavior
The request body should be converted to the parameters, with the in value of file, in the v2 spec.
Screenshots
When it uses the OpenAPI v3 spec, the request body is rendered with no issue.
{
"openapi": "3.0.1",
"paths": {
"/pet/{petId}/uploadImage": {
"post": {
"operationId": "uploadFile",
"parameters": [
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/petFormData"
}
}
}
},
}
},
},
"components": {
"schemas": {
"petFormData": {
"type": "object",
"properties": {
"additionalMetadata": {
"type": "string",
"description": "Additional data to pass to server"
},
"file": {
"type": "string",
"description": "File to upload",
"format": "binary"
}
}
}
}
}
}However, when it uses the OpenAPI spec v2, the request body is missing – it should be converted to a parameter of file.
{
"swagger": "2.0",
"paths": {
"/pet/{petId}/uploadImage": {
"post": {
"operationId": "uploadFile",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "path",
"name": "petId",
"required": true,
"type": "integer",
"format": "int64"
}
]
}
}
},
"definitions": {
"petFormData": {
"type": "object",
"properties": {
"additionalMetadata": {
"description": "Additional data to pass to server",
"type": "string"
},
"file": {
"format": "binary",
"description": "File to upload",
"type": "string"
}
}
}
}
}Additional context
It's because the referencing NuGet package, OpenAPI.NET v1.2.3 doesn't pick up the request body schema reference. This PR over OpenAPI.NET partially fixed this issue – it only looked after the request body properties, not reference.