swagger-axios-codegen
swagger-axios-codegen copied to clipboard
Code generated for APIs requiring text/plain (etc.) as request content type not useful
We have a couple of APIs for uploading documents, that in our swagger look like, e.g.:
"/v1/validateFile": {
"post": {
"operationId": "validateFile",
"consumes": [
"text/plain"
],
"produces": [
"application/json"
],
But the function generated by swagger-axios-codegen has
let data = null
configs.data = data
axios(configs, resolve, reject)
i.e., there's no way to pass in the actual contents to upload to the API!
Again, I could look at contributing a fix, but is this something you'd come across before?
We also have some APIs that require application/octet-stream as the input (binary file uploads).
Thanks!
Dylan
Only Application/JSON and Multipart/form-Data are implemented
Are you happy for me to contribute a fix? Intention would be to add an extra string parameter 'content' to the client method (would need to check for an existing such param obviously).
This is still something I believe swagger codegen would benefit from, and I was happy to contribute an implementation, but I'd hoped for confirmation that you thought my proposal made sense...
so, what your mean? and codegen result like ?do you provide an example?
Completed untested, but perhaps something like
static validateFile(
content?: string,
options: IRequestOptions = {},
): Promise<ValidateFileResponse> {
return new Promise((resolve, reject) => {
let url = '/v1/validateFile'
const configs: IRequestConfig = getConfigs('post', 'text/plain', url, options)
configs.data = content
axios(configs, resolve, reject)
})
}```
look forward to you submit full example