@@ -28,6 +28,7 @@ const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/sc
28
28
APP_JSON = 'application/json' ,
29
29
APP_JS = 'application/javascript' ,
30
30
TEXT_XML = 'text/xml' ,
31
+ APP_XML = 'application/xml' ,
31
32
TEXT_PLAIN = 'text/plain' ,
32
33
TEXT_HTML = 'text/html' ,
33
34
FORM_DATA = 'multipart/form-data' ,
@@ -1910,6 +1911,7 @@ module.exports = {
1910
1911
else if ( contentObj . hasOwnProperty ( APP_JSON ) ) { bodyType = APP_JSON ; }
1911
1912
else if ( contentObj . hasOwnProperty ( TEXT_HTML ) ) { bodyType = TEXT_HTML ; }
1912
1913
else if ( contentObj . hasOwnProperty ( TEXT_PLAIN ) ) { bodyType = TEXT_PLAIN ; }
1914
+ else if ( contentObj . hasOwnProperty ( APP_XML ) ) { bodyType = APP_XML ; }
1913
1915
else if ( contentObj . hasOwnProperty ( TEXT_XML ) ) { bodyType = TEXT_XML ; }
1914
1916
else {
1915
1917
// take the first property it has
@@ -1930,20 +1932,24 @@ module.exports = {
1930
1932
} ;
1931
1933
}
1932
1934
else {
1933
- bodyData = this . convertToPmBodyData ( contentObj [ bodyType ] , requestType , bodyType ,
1934
- PARAMETER_SOURCE . REQUEST , options . indentCharacter , components , options , schemaCache ) ;
1935
1935
let getXmlVersionContent = ( bodyContent ) => {
1936
1936
const regExp = new RegExp ( '([<\\?xml]+[\\s{1,}]+[version="\\d.\\d"]+[\\sencoding="]+.{1,15}"\\?>)' ) ;
1937
1937
let xmlBody = bodyContent ;
1938
+
1938
1939
if ( ! bodyContent . match ( regExp ) ) {
1939
- const versionContent = '<?xml version="1.0" encoding="utf -8"?>' ;
1940
+ const versionContent = '<?xml version="1.0" encoding="UTF -8"?>\n ' ;
1940
1941
xmlBody = versionContent + xmlBody ;
1941
1942
}
1942
1943
return xmlBody ;
1943
1944
} ;
1944
- bodyData = bodyType === TEXT_XML ?
1945
+
1946
+ bodyData = this . convertToPmBodyData ( contentObj [ bodyType ] , requestType , bodyType ,
1947
+ PARAMETER_SOURCE . REQUEST , options . indentCharacter , components , options , schemaCache ) ;
1948
+
1949
+ bodyData = ( bodyType === TEXT_XML || bodyType === APP_XML ) ?
1945
1950
getXmlVersionContent ( bodyData ) :
1946
1951
bodyData ;
1952
+
1947
1953
updateOptions = {
1948
1954
mode : rDataMode ,
1949
1955
raw : bodyType !== APP_JSON ?
0 commit comments