mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Check for type and format in the original param instead of checking for value after processing
This commit is contained in:
@@ -337,7 +337,7 @@ module.exports = {
|
||||
|
||||
// Discard format if not supported by both json-schema-faker and ajv or pattern is also defined
|
||||
if (!_.includes(SUPPORTED_FORMATS, schema.format) || (schema.pattern && schema.format)) {
|
||||
delete schema.format;
|
||||
return _.omit(schema, 'format');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1701,6 +1701,7 @@ module.exports = {
|
||||
var contentObj, // content is required
|
||||
bodyData,
|
||||
param,
|
||||
originalParam,
|
||||
paramArray = [],
|
||||
updateOptions = {},
|
||||
reqBody = new sdk.RequestBody(),
|
||||
@@ -1832,8 +1833,14 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
// Set param type to 'file' for binary value
|
||||
if (value === '<binary>') {
|
||||
// Fetch the original param and if it is of type 'string' and format 'binary'
|
||||
// then set the type of FormParam to 'file'
|
||||
originalParam = _.get(contentObj[FORM_DATA], ['schema', 'properties', key]);
|
||||
|
||||
if (originalParam &&
|
||||
originalParam.type === 'string' &&
|
||||
originalParam.format === 'binary'
|
||||
) {
|
||||
param = new sdk.FormParam({
|
||||
key: key,
|
||||
value: '',
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('DEREF FUNCTION TESTS ', function() {
|
||||
type: 'object',
|
||||
description: 'Schema 2',
|
||||
properties: {
|
||||
id: { default: '<long>', type: 'integer' },
|
||||
id: { default: '<long>', type: 'integer', format: 'int64' },
|
||||
test_prop: { default: '<string>', type: 'string' }
|
||||
}
|
||||
});
|
||||
@@ -302,6 +302,8 @@ describe('DEREF FUNCTION TESTS ', function() {
|
||||
expect(_.get(schemaResoltionCache, ['#/components/schemas/schemaUsed', 'schema'])).to.not.deep
|
||||
.equal(componentsAndPaths.components.schemas.schemaUsed);
|
||||
resolvedSchema = deref.resolveRefs(schema, parameterSource, componentsAndPaths, schemaResoltionCache);
|
||||
// Restoring the original format as it is deleted if not supported by json-schema-faker and ajv
|
||||
resolvedSchema.properties.id.format = 'int64';
|
||||
|
||||
/**
|
||||
* Even though schema cache contains schemaUsed as impartially cached,resolution were it's used again will
|
||||
|
||||
Reference in New Issue
Block a user