openapi-to-postmanv2
Advanced tools
Comparing version 4.9.0-beta.10 to 4.9.0-beta.11
'use strict'; | ||
const { MODULE_VERSION } = require('./lib/schemapack.js'); | ||
const _ = require('lodash'), | ||
@@ -18,3 +20,3 @@ SchemaPack = require('./lib/schemapack.js').SchemaPack; | ||
convertV2: function(input, options, cb) { | ||
var schema = new SchemaPack(input, options); | ||
var schema = new SchemaPack(input, options, MODULE_VERSION.V2); | ||
@@ -21,0 +23,0 @@ if (schema.validated) { |
@@ -8,3 +8,7 @@ const { filterOptionsByVersion } = require('./common/versionUtils'); | ||
VERSION20 = '2.0', | ||
SUPPORTED_VERSIONS = [VERSION20, VERSION30, VERSION31]; | ||
SUPPORTED_VERSIONS = [VERSION20, VERSION30, VERSION31], | ||
MODULE_VERSION = { | ||
V1: 'v1', | ||
V2: 'v2' | ||
}; | ||
@@ -71,3 +75,4 @@ /** | ||
usage: ['CONVERSION', 'VALIDATION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -83,3 +88,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -95,3 +101,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V1] | ||
}, | ||
@@ -107,3 +114,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V1] | ||
}, | ||
@@ -122,3 +130,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V1] | ||
}, | ||
@@ -137,5 +146,21 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V1] | ||
}, | ||
{ | ||
name: 'Parameter generation', | ||
id: 'parametersResolution', | ||
type: 'enum', | ||
default: 'Schema', | ||
availableOptions: ['Example', 'Schema'], | ||
description: 'Select whether to generate the request and response parameters based on the' + | ||
' [schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject) or the' + | ||
' [example](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject)' + | ||
' in the schema.', | ||
external: true, | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2] | ||
}, | ||
{ | ||
name: 'Folder organization', | ||
@@ -149,3 +174,4 @@ id: 'folderStrategy', | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -160,3 +186,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -173,3 +200,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -184,3 +212,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -195,3 +224,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -208,3 +238,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -220,3 +251,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -232,3 +264,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -243,3 +276,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -254,3 +288,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -265,3 +300,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -277,3 +313,4 @@ { | ||
usage: ['VALIDATION'], | ||
supportedIn: [VERSION30, VERSION31] | ||
supportedIn: [VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -289,3 +326,4 @@ { | ||
supportedIn: [VERSION30, VERSION31], | ||
usage: ['VALIDATION'] | ||
usage: ['VALIDATION'], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -301,3 +339,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -312,3 +351,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -323,3 +363,4 @@ { | ||
usage: ['CONVERSION'], | ||
supportedIn: [VERSION31] | ||
supportedIn: [VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -334,3 +375,4 @@ { | ||
usage: ['BUNDLE'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
}, | ||
@@ -346,3 +388,4 @@ { | ||
usage: ['CONVERSION', 'VALIDATION'], | ||
supportedIn: [VERSION20, VERSION30, VERSION31] | ||
supportedIn: [VERSION20, VERSION30, VERSION31], | ||
supportedModuleVersion: [MODULE_VERSION.V2, MODULE_VERSION.V1] | ||
} | ||
@@ -364,2 +407,13 @@ ]; | ||
} | ||
if (_.has(criteria, 'moduleVersion')) { | ||
optsArray = _.filter(optsArray, (option) => { | ||
return _.includes(option.supportedModuleVersion, criteria.moduleVersion); | ||
}); | ||
} | ||
else { | ||
optsArray = _.filter(optsArray, (option) => { | ||
return _.includes(option.supportedModuleVersion, MODULE_VERSION.V1); | ||
}); | ||
} | ||
} | ||
@@ -366,0 +420,0 @@ |
@@ -30,3 +30,7 @@ 'use strict'; | ||
v2 = require('../libV2/index'), | ||
{ getServersPathVars } = require('./common/schemaUtilsCommon.js'); | ||
{ getServersPathVars } = require('./common/schemaUtilsCommon.js'), | ||
MODULE_VERSION = { | ||
V1: 'v1', | ||
V2: 'v2' | ||
}; | ||
@@ -38,3 +42,3 @@ let path = require('path'), | ||
class SchemaPack { | ||
constructor (input, options = {}) { | ||
constructor (input, options = {}, moduleVersion = MODULE_VERSION.V1) { | ||
if (input.type === schemaUtils.MULTI_FILE_API_TYPE_ALLOWED_VALUE && | ||
@@ -48,3 +52,5 @@ input.data && input.data[0] && input.data[0].path) { | ||
this.validationResult = null; | ||
this.definedOptions = getOptions(); | ||
this.definedOptions = getOptions({ | ||
moduleVersion | ||
}); | ||
this.computedOptions = null; | ||
@@ -814,3 +820,4 @@ this.schemaFakerCache = {}; | ||
module.exports = { | ||
SchemaPack | ||
SchemaPack, | ||
MODULE_VERSION | ||
}; |
@@ -658,4 +658,4 @@ const generateAuthForCollectionFromOpenAPI = require('./helpers/collection/generateAuthForCollectionFromOpenAPI'); | ||
resolvedSchema = resolveSchema(context, param.schema), | ||
{ requestParametersResolution } = context.computedOptions, | ||
shouldGenerateFromExample = requestParametersResolution === 'example', | ||
{ parametersResolution } = context.computedOptions, | ||
shouldGenerateFromExample = parametersResolution === 'example', | ||
hasExample = param.example !== undefined || | ||
@@ -907,5 +907,5 @@ param.schema.example !== undefined || | ||
resolveRequestBodyData = (context, requestBodySchema, bodyType) => { | ||
let { requestParametersResolution, indentCharacter } = context.computedOptions, | ||
let { parametersResolution, indentCharacter } = context.computedOptions, | ||
bodyData = '', | ||
shouldGenerateFromExample = requestParametersResolution === 'example', | ||
shouldGenerateFromExample = parametersResolution === 'example', | ||
example, | ||
@@ -912,0 +912,0 @@ examples; |
{ | ||
"name": "openapi-to-postmanv2", | ||
"version": "4.9.0-beta.10", | ||
"version": "4.9.0-beta.11", | ||
"description": "Convert a given OpenAPI specification to Postman Collection v2.0", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/postmanlabs/openapi-to-postman", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1689621
43342
3