mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Merge branch 'develop' into fix479/valueTypes
This commit is contained in:
@@ -651,6 +651,10 @@ module.exports = {
|
||||
variableStore = {},
|
||||
webhooksVariables = [];
|
||||
|
||||
if (Object.keys(webhooksTree.root.children).length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let child in webhooksTree.root.children) {
|
||||
if (
|
||||
webhooksTree.root.children.hasOwnProperty(child) &&
|
||||
@@ -902,7 +906,7 @@ module.exports = {
|
||||
convertPathVariables: function(type, providedPathVars, commonPathVars, components, options, schemaCache) {
|
||||
options = _.merge({}, defaultOptions, options);
|
||||
|
||||
var variables = providedPathVars;
|
||||
var variables = [];
|
||||
// converting the base uri path variables, if any
|
||||
// commonPathVars is an object for type = root/method
|
||||
// array otherwise
|
||||
@@ -935,7 +939,8 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
return variables;
|
||||
// keep already provided varables (server variables) at last
|
||||
return _.concat(variables, providedPathVars);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1416,8 +1421,13 @@ module.exports = {
|
||||
else if (bodyObj.schema) {
|
||||
if (bodyObj.schema.hasOwnProperty('$ref')) {
|
||||
let outerProps = concreteUtils.getOuterPropsIfIsSupported(bodyObj.schema),
|
||||
resolvedSchema;
|
||||
|
||||
// skip beforehand resolution for OAS 3.0
|
||||
if (outerProps) {
|
||||
resolvedSchema = this.getRefObject(bodyObj.schema.$ref, components, options);
|
||||
bodyObj.schema = concreteUtils.addOuterPropsToRefSchemaIfIsSupported(resolvedSchema, outerProps);
|
||||
bodyObj.schema = concreteUtils.addOuterPropsToRefSchemaIfIsSupported(resolvedSchema, outerProps);
|
||||
}
|
||||
}
|
||||
if (options.schemaFaker) {
|
||||
if (this.getHeaderFamily(contentType) === HEADER_TYPE.XML) {
|
||||
@@ -1425,7 +1435,7 @@ module.exports = {
|
||||
}
|
||||
// Do not fake schemas if the complexity score is 10
|
||||
if (options.complexityScore === 10) {
|
||||
schemaType = bodyObj.schema.type;
|
||||
schemaType = _.get(this.getRefObject(bodyObj.schema.$ref, components, options), 'type');
|
||||
if (schemaType === 'object') {
|
||||
return {
|
||||
value: '<Error: Spec size too large, skipping faking of schemas>'
|
||||
@@ -1747,12 +1757,14 @@ module.exports = {
|
||||
// handling for the urlencoded media type
|
||||
if (contentObj.hasOwnProperty(URLENCODED)) {
|
||||
rDataMode = 'urlencoded';
|
||||
if (contentObj[URLENCODED].hasOwnProperty('schema') && contentObj[URLENCODED].schema.hasOwnProperty('$ref')) {
|
||||
contentObj[URLENCODED].schema = this.getRefObject(contentObj[URLENCODED].schema.$ref, components, options);
|
||||
}
|
||||
bodyData = this.convertToPmBodyData(contentObj[URLENCODED], requestType, URLENCODED,
|
||||
PARAMETER_SOURCE.REQUEST, options.indentCharacter, components, options, schemaCache);
|
||||
encoding = contentObj[URLENCODED].encoding ? contentObj[URLENCODED].encoding : {};
|
||||
|
||||
if (contentObj[URLENCODED].hasOwnProperty('schema') && contentObj[URLENCODED].schema.hasOwnProperty('$ref')) {
|
||||
contentObj[URLENCODED].schema = this.getRefObject(contentObj[URLENCODED].schema.$ref, components, options);
|
||||
}
|
||||
|
||||
// create query parameters and add it to the request body object
|
||||
_.forOwn(bodyData, (value, key) => {
|
||||
|
||||
@@ -2041,6 +2053,10 @@ module.exports = {
|
||||
options = _.merge({}, defaultOptions, options);
|
||||
var refObj, savedSchema;
|
||||
|
||||
if (typeof $ref !== 'string') {
|
||||
return { value: `Invalid $ref: ${$ref} was found` };
|
||||
}
|
||||
|
||||
savedSchema = $ref.split('/').slice(1).map((elem) => {
|
||||
// https://swagger.io/docs/specification/using-ref#escape
|
||||
// since / is the default delimiter, slashes are escaped with ~1
|
||||
@@ -2223,10 +2239,10 @@ module.exports = {
|
||||
pmBody,
|
||||
authMeta,
|
||||
swagResponse,
|
||||
localServers = _.get(operationItem, 'properties.servers'),
|
||||
localServers = fromWebhooks ? '' : _.get(operationItem, 'properties.servers'),
|
||||
exampleRequestBody,
|
||||
sanitizeResult,
|
||||
globalServers = _.get(operationItem, 'servers'),
|
||||
globalServers = fromWebhooks ? '' : _.get(operationItem, 'servers'),
|
||||
responseMediaTypes,
|
||||
acceptHeader;
|
||||
|
||||
@@ -2332,6 +2348,7 @@ module.exports = {
|
||||
if (fromWebhooks) {
|
||||
reqName = utils.insertSpacesInName(operation.operationId) ||
|
||||
operation.summary ||
|
||||
operation.description ||
|
||||
`${this.cleanWebhookName(operationItem.path)} - ${operationItem.method}`;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user