Read "consumes" and write into "headers"
Closed this issue · 6 comments
From the specification there can be a consumes
property. We should read it and add it to the "headers" section within the AxiosRequestConfig
object.
Example:
"/api/v1/exchange/{id}": {
"delete": {
"consumes": [
"application/json"
],
// ...
}
->
const config: AxiosRequestConfig = {
headers: { 'content-type': 'application/json' },
// ...
};
@bennyn What if consumes
contains multiple entries?
Example:
"/api/v1/exchange/{id}": {
"delete": {
"consumes": [
"application/json",
"application/xml"
],
// ...
}
Hmm. I haven't thought of that case. If we don't set the 'content-type'
, then axios will automatically assign one. I think we should stay with this implementation until it becomes a problem.
We could use this idea to filter out paths which only consume "application/xml" since Swaxios can't handle these anyway.
I think axios supports XML too so we should be good with it's auto detection mode for now. I would close this issue until it becomes a problem. WDYT?
Sounds good!
Btw, we should probably change the return type of an endpoint which returns XML to "string".