@@ -55,6 +55,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
5555 valuePropInExample = path . join ( __dirname , VALID_OPENAPI_PATH , '/valuePropInExample.yaml' ) ,
5656 petstoreParamExample = path . join ( __dirname , VALID_OPENAPI_PATH , '/petstoreParamExample.yaml' ) ,
5757 xmlrequestBody = path . join ( __dirname , VALID_OPENAPI_PATH , '/xmlExample.yaml' ) ,
58+ xmlrequestExampleBody = path . join ( __dirname , VALID_OPENAPI_PATH , '/xmlExampleWithString.yaml' ) ,
5859 queryParamWithEnumResolveAsExample =
5960 path . join ( __dirname , VALID_OPENAPI_PATH , '/query_param_with_enum_resolve_as_example.json' ) ,
6061 formDataParamDescription = path . join ( __dirname , VALID_OPENAPI_PATH , '/form_data_param_description.yaml' ) ,
@@ -1255,6 +1256,25 @@ describe('CONVERT FUNCTION TESTS ', function() {
12551256 } ) ;
12561257 } ) ;
12571258
1259+ it ( 'Should convert xml request body with complete string example correctly' , function ( done ) {
1260+ const openapi = fs . readFileSync ( xmlrequestExampleBody , 'utf8' ) ;
1261+ Converter . convert ( { type : 'string' , data : openapi } ,
1262+ { schemaFaker : true , requestParametersResolution : 'Example' } , ( err , conversionResult ) => {
1263+ expect ( err ) . to . be . null ;
1264+ expect ( conversionResult . result ) . to . equal ( true ) ;
1265+ expect ( conversionResult . output [ 0 ] . data . item [ 0 ] . request . body . raw )
1266+ . to . equal ( `<?xml version="1.0" encoding="UTF-8"?>
1267+ <Errors>
1268+ <error>
1269+ <issue>Mandatory field are missing.</issue>
1270+ <action>Resend request with valid values, any one of Hello or World.</action>
1271+ </error>
1272+ </Errors>
1273+ ` ) ;
1274+ done ( ) ;
1275+ } ) ;
1276+ } ) ;
1277+
12581278 it ( '[Github #518]- integer query params with enum values get default value of NaN' +
12591279 descriptionInBodyParams , function ( done ) {
12601280 var openapi = fs . readFileSync ( queryParamWithEnumResolveAsExample , 'utf8' ) ;
@@ -1910,7 +1930,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
19101930
19111931 it ( 'Should add corresponding Accept header in collection example\'s request correctly' , function ( done ) {
19121932 var openapi = fs . readFileSync ( acceptHeaderExample , 'utf8' ) ;
1913- Converter . convertV2 ( { type : 'string' , data : openapi } , { } ,
1933+ Converter . convert ( { type : 'string' , data : openapi } , { } ,
19141934 ( err , conversionResult ) => {
19151935 expect ( err ) . to . be . null ;
19161936 expect ( conversionResult . result ) . to . equal ( true ) ;
@@ -1920,8 +1940,8 @@ describe('CONVERT FUNCTION TESTS ', function() {
19201940 expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'item' ) ;
19211941 expect ( conversionResult . output [ 0 ] . data . item . length ) . to . equal ( 1 ) ;
19221942
1923- const item1 = conversionResult . output [ 0 ] . data . item [ 0 ] . item [ 0 ] . item [ 0 ] . item [ 0 ] ,
1924- item2 = conversionResult . output [ 0 ] . data . item [ 0 ] . item [ 1 ] . item [ 0 ] ,
1943+ const item1 = conversionResult . output [ 0 ] . data . item [ 0 ] . item [ 1 ] ,
1944+ item2 = conversionResult . output [ 0 ] . data . item [ 0 ] . item [ 0 ] ,
19251945 acceptHeader = {
19261946 key : 'Accept' ,
19271947 value : 'application/json'
0 commit comments