Conversation
|
Related OpenApi schema part "/api/ReturnFile": {
"get": {
"tags": [
"ReturnFile"
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/api/ReturnFile/single": {
"post": {
"tags": [
"ReturnFile"
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"file": {
"style": "form"
}
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/api/ReturnFile/multiple": {
"post": {
"tags": [
"ReturnFile"
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"type": "string",
"format": "binary"
}
}
}
},
"encoding": {
"files": {
"style": "form"
}
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "integer",
"format": "int32"
}
}
}
}
}
}
},
"/api/ReturnFile/form-with-file": {
"post": {
"tags": [
"ReturnFile"
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"Name": {
"type": "string"
},
"File": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"Name": {
"style": "form"
},
"File": {
"style": "form"
}
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
}, |
| let data = WebAPI.OperationTypes.PostApiReturnFileSingle_formData(toStream text) | ||
| let! stream = api.PostApiReturnFileSingle(data) |
There was a problem hiding this comment.
I am not supper happy that we generate wrapper object around payload ...
but in OpenAPI payload described as one parameter requestBody that we map to provided type
"/api/ReturnFile/single": {
"post": {
"tags": [
"ReturnFile"
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"file": {
"style": "form"
}
}
}
}
},| let filename = Guid.NewGuid().ToString() // asp.net core cannot deserialize IFormFile otherwise | ||
| cnt.Add(new StreamContent(stream), name, filename) |
There was a problem hiding this comment.
Another hack is that we have to provide file have for content disposition header, otherwise asp.net core backend cannot map it to IFormFile, but this is not reflected in OpenAPI schema :'(
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"file": {
"style": "form"
}
}
}
}
},|
I merge it, because it definitely better than nothing - we can improve in the future. |
|
@sergey-tihon this looks perfectly fine to me, thanks for carrying the torch here and adding this functionality :) As for your comment about needing the wrapper-type, that seems like something that can be added later as an additional overload if/when there's time. So then you'd have one overload with the wrapper-type (which you could mark as obsolete), and another overload with just the input stream (which I guess seems like the 'ideal' interface to me?) |
reworked version of #108 with desire to fix #59 and #61
Related links