mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
added test for convertPmBodyResponse function
This commit is contained in:
@@ -1164,10 +1164,12 @@ module.exports = {
|
||||
if (responseBodyWrapper.contentTypeHeader) {
|
||||
// we could infer the content-type header from the body
|
||||
responseHeaders.push({ key: 'Content-Type', value: responseBodyWrapper.contentTypeHeader });
|
||||
if (responseBodyWrapper.contentTypeHeader === APP_JSON) {
|
||||
if (this.checkHeaderType(responseBodyWrapper.contentTypeHeader) &&
|
||||
responseBodyWrapper.contentTypeHeader.endsWith('json')) {
|
||||
previewLanguage = 'json';
|
||||
}
|
||||
else if (responseBodyWrapper.contentTypeHeader === APP_XML) {
|
||||
else if (this.checkHeaderType(responseBodyWrapper.contentTypeHeader) &&
|
||||
responseBodyWrapper.contentTypeHeader.endsWith('xml')) {
|
||||
previewLanguage = 'xml';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1478,6 +1478,33 @@ describe('UTILITY FUNCTION TESTS ', function () {
|
||||
expect(pmResponseBody.id).to.equal('<long>');
|
||||
expect(pmResponseBody.name).to.equal('<string>');
|
||||
});
|
||||
it('with Content-Type application/vnd.retailer.v2+json', function() {
|
||||
var contentObj = {
|
||||
'application/vnd.retailer.v2+json': {
|
||||
'schema': {
|
||||
'type': 'object',
|
||||
'required': [
|
||||
'id',
|
||||
'name'
|
||||
],
|
||||
'properties': {
|
||||
id: {
|
||||
type: 'integer',
|
||||
format: 'int64'
|
||||
},
|
||||
name: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
pmResponseBody;
|
||||
Utils.options.schemaFaker = true;
|
||||
pmResponseBody = JSON.parse(Utils.convertToPmResponseBody(contentObj).responseBody);
|
||||
expect(pmResponseBody.id).to.equal('<long>');
|
||||
expect(pmResponseBody.name).to.equal('<string>');
|
||||
});
|
||||
it('with Content-Type application/vnd.api+json', function() {
|
||||
var contentObj = {
|
||||
'application/vnd.api+json': {
|
||||
|
||||
Reference in New Issue
Block a user