@@ -1928,6 +1928,70 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
1928
1928
expect ( result . body . mode ) . to . equal ( 'file' ) ;
1929
1929
done ( ) ;
1930
1930
} ) ;
1931
+ it ( ' application/vnd.api+json (headers with different structure but still of JSON type/family)' , function ( done ) {
1932
+ var requestBody = {
1933
+ description : 'body description' ,
1934
+ content : {
1935
+ 'application/vnd.api+json' : {
1936
+ 'schema' : {
1937
+ type : 'object' ,
1938
+ required : [
1939
+ 'id' ,
1940
+ 'name'
1941
+ ] ,
1942
+ properties : {
1943
+ id : {
1944
+ type : 'integer' ,
1945
+ format : 'int64'
1946
+ } ,
1947
+ name : {
1948
+ type : 'string'
1949
+ } ,
1950
+ neglect : { // this will be neglected since schemaFaker does not process
1951
+ type : 'string' ,
1952
+ format : 'binary'
1953
+ }
1954
+ }
1955
+ }
1956
+ }
1957
+ }
1958
+ } ,
1959
+ result , resultBody ;
1960
+ result = SchemaUtils . convertToPmBody ( requestBody ) ;
1961
+ resultBody = JSON . parse ( result . body . raw ) ;
1962
+ expect ( resultBody . id ) . to . equal ( '<long>' ) ;
1963
+ expect ( resultBody . name ) . to . equal ( '<string>' ) ;
1964
+ expect ( result . contentHeader ) . to . deep . include ( { key : 'Content-Type' , value : 'application/vnd.api+json' } ) ;
1965
+ expect ( result . body . options . raw . language ) . to . equal ( 'json' ) ;
1966
+ done ( ) ;
1967
+ } ) ;
1968
+ it ( ' application/vnd.api+xml (headers with different structure but still of XML type/family)' , function ( done ) {
1969
+ var requestBody = {
1970
+ description : 'body description' ,
1971
+ content : {
1972
+ 'application/vnd.api+xml' : {
1973
+ examples : {
1974
+ xml : {
1975
+ summary : 'A list containing two items' ,
1976
+ value : '<AnXMLObject>test</AnXMLObject>'
1977
+ }
1978
+ }
1979
+ }
1980
+ }
1981
+ } ,
1982
+ result , resultBody ;
1983
+ result = SchemaUtils . convertToPmBody ( requestBody , 'ROOT' , { } , {
1984
+ requestParametersResolution : 'example'
1985
+ } ) ;
1986
+ resultBody = ( result . body . raw ) ;
1987
+ expect ( resultBody ) . to . equal (
1988
+ '<?xml version="1.0" encoding="UTF-8"?>\n<AnXMLObject>test</AnXMLObject>'
1989
+ ) ;
1990
+ expect ( result . contentHeader ) . to . deep . include (
1991
+ { key : 'Content-Type' , value : 'application/vnd.api+xml' } ) ;
1992
+ expect ( result . body . options . raw . language ) . to . equal ( 'xml' ) ;
1993
+ done ( ) ;
1994
+ } ) ;
1931
1995
// things remaining : application/xml
1932
1996
} ) ;
1933
1997
} ) ;
0 commit comments