mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Merge pull request #412 from postmanlabs/issue/382
Handle the case when request body is of type `string` and format `binary`
This commit is contained in:
@@ -134,7 +134,8 @@
|
||||
"raw",
|
||||
"urlencoded",
|
||||
"formdata",
|
||||
"graphql"
|
||||
"graphql",
|
||||
"file"
|
||||
]
|
||||
},
|
||||
"raw": {
|
||||
|
||||
@@ -1873,6 +1873,17 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
bodyType &&
|
||||
!_.isEmpty(_.get(contentObj, [bodyType, 'schema'])) &&
|
||||
contentObj[bodyType].schema.type === 'string' &&
|
||||
contentObj[bodyType].schema.format === 'binary'
|
||||
) {
|
||||
updateOptions = {
|
||||
mode: 'file'
|
||||
};
|
||||
}
|
||||
else {
|
||||
bodyData = this.convertToPmBodyData(contentObj[bodyType], requestType, bodyType,
|
||||
PARAMETER_SOURCE.REQUEST, options.indentCharacter, components, options, schemaCache);
|
||||
|
||||
@@ -1880,6 +1891,7 @@ module.exports = {
|
||||
mode: rDataMode,
|
||||
raw: JSON.stringify(bodyData, null, 4)
|
||||
};
|
||||
}
|
||||
|
||||
contentHeader = new sdk.Header({
|
||||
key: 'Content-Type',
|
||||
|
||||
@@ -1692,6 +1692,24 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
|
||||
{ key: 'Content-Type', value: 'application/javascript' });
|
||||
done();
|
||||
});
|
||||
it(' image/*', function (done) {
|
||||
var requestBody = {
|
||||
description: 'body description',
|
||||
content: {
|
||||
'image/*': {
|
||||
schema: {
|
||||
type: 'string',
|
||||
format: 'binary'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
result;
|
||||
|
||||
result = SchemaUtils.convertToPmBody(requestBody);
|
||||
expect(result.body.mode).to.equal('file');
|
||||
done();
|
||||
});
|
||||
// things remaining : application/xml
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user