Merge branch 'develop' of github.com:postmanlabs/openapi-to-postman into develop

This commit is contained in:
Vishal Shingala
2022-07-12 15:13:35 +05:30
56 changed files with 10746 additions and 153 deletions

View File

@@ -123,6 +123,9 @@ function getConcreteSchemaUtils({ type, data }) {
if (specVersion === DEFAULT_SPEC_VERSION) { if (specVersion === DEFAULT_SPEC_VERSION) {
concreteUtils = require('../30XUtils/schemaUtils30X'); concreteUtils = require('../30XUtils/schemaUtils30X');
} }
else if (specVersion === VERSION_20.version) {
concreteUtils = require('../swaggerUtils/schemaUtilsSwagger');
}
else { else {
concreteUtils = require('../31XUtils/schemaUtils31X'); concreteUtils = require('../31XUtils/schemaUtils31X');
} }
@@ -142,8 +145,22 @@ function filterOptionsByVersion(options, version) {
return options; return options;
} }
/**
* Calculates if thew current input is using swagger 2.0 spec
* @param {string} version The current spec version
* @returns {boolean} True if the current spec is using swagger 2.0 spec
*/
function isSwagger(version) {
let isSwagger = false;
if (version === VERSION_20.version) {
isSwagger = true;
}
return isSwagger;
}
module.exports = { module.exports = {
getSpecVersion, getSpecVersion,
getConcreteSchemaUtils, getConcreteSchemaUtils,
filterOptionsByVersion filterOptionsByVersion,
isSwagger
}; };

View File

@@ -4,7 +4,8 @@ const _ = require('lodash'),
VALID_MODES = ['document', 'use'], VALID_MODES = ['document', 'use'],
VERSION30 = '3.0', VERSION30 = '3.0',
VERSION31 = '3.1', VERSION31 = '3.1',
SUPPORTED_VERSIONS = [VERSION30, VERSION31]; VERSION20 = '2.0',
SUPPORTED_VERSIONS = [VERSION20, VERSION30, VERSION31];
/** /**
* Takes a list of arguments and resolve them acording its content * Takes a list of arguments and resolve them acording its content
@@ -66,7 +67,7 @@ module.exports = {
' values: `description`, `operationid`, `url`.', ' values: `description`, `operationid`, `url`.',
external: true, external: true,
usage: ['CONVERSION', 'VALIDATION'], usage: ['CONVERSION', 'VALIDATION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Set indent character', name: 'Set indent character',
@@ -77,7 +78,7 @@ module.exports = {
description: 'Option for setting indentation character', description: 'Option for setting indentation character',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Collapse redundant folders', name: 'Collapse redundant folders',
@@ -88,7 +89,7 @@ module.exports = {
'persistent folder-level data.', 'persistent folder-level data.',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Optimize conversion', name: 'Optimize conversion',
@@ -99,7 +100,7 @@ module.exports = {
' the performance of conversion.', ' the performance of conversion.',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Request parameter generation', name: 'Request parameter generation',
@@ -113,7 +114,7 @@ module.exports = {
' in the schema.', ' in the schema.',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Response parameter generation', name: 'Response parameter generation',
@@ -127,7 +128,7 @@ module.exports = {
' in the schema.', ' in the schema.',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Folder organization', name: 'Folder organization',
@@ -138,7 +139,7 @@ module.exports = {
description: 'Select whether to create folders according to the specs paths or tags.', description: 'Select whether to create folders according to the specs paths or tags.',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Enable Schema Faking', name: 'Enable Schema Faking',
@@ -148,7 +149,7 @@ module.exports = {
description: 'Whether or not schemas should be faked.', description: 'Whether or not schemas should be faked.',
external: false, external: false,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Schema resolution nesting limit', name: 'Schema resolution nesting limit',
@@ -160,7 +161,7 @@ module.exports = {
' option works correctly "optimizeConversion" option needs to be disabled)', ' option works correctly "optimizeConversion" option needs to be disabled)',
external: false, external: false,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Include auth info in example requests', name: 'Include auth info in example requests',
@@ -170,7 +171,7 @@ module.exports = {
description: 'Select whether to include authentication parameters in the example request', description: 'Select whether to include authentication parameters in the example request',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Short error messages during request <> schema validation', name: 'Short error messages during request <> schema validation',
@@ -276,7 +277,7 @@ module.exports = {
description: 'Whether to set optional parameters as disabled', description: 'Whether to set optional parameters as disabled',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Keep implicit headers', name: 'Keep implicit headers',
@@ -286,7 +287,7 @@ module.exports = {
description: 'Whether to keep implicit headers from the OpenAPI specification, which are removed by default.', description: 'Whether to keep implicit headers from the OpenAPI specification, which are removed by default.',
external: true, external: true,
usage: ['CONVERSION'], usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31] supportedIn: [VERSION20, VERSION30, VERSION31]
}, },
{ {
name: 'Include webhooks', name: 'Include webhooks',

View File

@@ -3,6 +3,7 @@
// This is the default collection name if one can't be inferred from the OpenAPI spec // This is the default collection name if one can't be inferred from the OpenAPI spec
const COLLECTION_NAME = 'Imported from OpenAPI 3.0', const COLLECTION_NAME = 'Imported from OpenAPI 3.0',
{ getConcreteSchemaUtils } = require('./common/versionUtils.js'), { getConcreteSchemaUtils } = require('./common/versionUtils.js'),
{ convertToOAS30IfSwagger } = require('./swaggerUtils/swaggerToOpenapi.js'),
BROWSER = 'browser', BROWSER = 'browser',
Ajv = require('ajv'), Ajv = require('ajv'),
addFormats = require('ajv-formats'), addFormats = require('ajv-formats'),
@@ -60,7 +61,10 @@ class SchemaPack {
validate() { validate() {
let input = this.input, let input = this.input,
json, json,
specParseResult; specParseResult,
isFolder = this.input.type === 'folder';
this.computedOptions = Object.assign({ isFolder }, this.computedOptions);
if (!input) { if (!input) {
return { return {
result: false, result: false,
@@ -252,6 +256,13 @@ class SchemaPack {
return callback(new OpenApiErr('The schema must be validated before attempting conversion')); return callback(new OpenApiErr('The schema must be validated before attempting conversion'));
} }
// We only convert if swagger is found otherwise this.openapi remains the same
convertToOAS30IfSwagger(concreteUtils, this.openapi, (error, newOpenapi) => {
if (error) {
return callback(error);
}
this.openapi = newOpenapi;
// this cannot be attempted before validation // this cannot be attempted before validation
specComponentsAndUtils = { concreteUtils }; specComponentsAndUtils = { concreteUtils };
Object.assign(specComponentsAndUtils, concreteUtils.getRequiredData(this.openapi)); Object.assign(specComponentsAndUtils, concreteUtils.getRequiredData(this.openapi));
@@ -360,6 +371,7 @@ class SchemaPack {
data: collectionJSON data: collectionJSON
}] }]
}); });
});
} }
/** /**

View File

@@ -0,0 +1,42 @@
module.exports = {
/**
* Validate Spec to check if some of the required fields are present.
* @param {Object} spec OpenAPI spec
* @param {object} options Validation options
* @return {Object} Validation result
*/
validateSpec: function (spec, options) {
if (spec.swagger !== '2.0') {
return {
result: false,
reason: 'The value of "swagger" field must be 2.0'
};
}
if (!spec.info) {
return {
result: false,
reason: 'The Swagger specification must have an "info" field'
};
}
if (!(spec.info.title && spec.info.version) && !options.isFolder) {
return {
result: false,
reason: 'Title, and version fields are required for the Info Object'
};
}
if (!spec.paths) {
return {
result: false,
reason: 'The Swagger specification must have a "paths" field'
};
}
// Valid. No reason needed
return {
result: true,
openapi: spec
};
}
};

View File

@@ -0,0 +1,74 @@
const inputValidationSwagger = require('./inputValidationSwagger'),
schemaUtilsCommon = require('../common/schemaUtilsCommon'),
_ = require('lodash');
module.exports = {
version: '2.0',
/**
* Parses an OAS string/object as a YAML or JSON
* @param {YAML/JSON} openApiSpec - The swagger 2.0 specification specified in either YAML or JSON
* @param {Object} options computed process options
* @returns {Object} - Contains the parsed JSON-version of the OAS spec, or an error
* @no-unit-test
*/
parseSpec: function (openApiSpec, options) {
return schemaUtilsCommon.parseSpec(openApiSpec, inputValidationSwagger, options);
},
/**
* Get the required elements for conversion from spec parsed data
* @param {object} spec openapi parsed value
* @returns {object} required elements to convert
*/
getRequiredData: function(spec) {
return {
info: spec.info,
components: spec.components ? spec.components : [],
paths: spec.paths
};
},
/**
* Compares two types and return if they match or not
* @param {string} currentType the type in schema
* @param {string} typeToValidate the type to compare
* @returns {boolean} the result of the comparation
*/
compareTypes(currentType, typeToValidate) {
return currentType === typeToValidate;
},
/**
* This method is to make this module matches with schemaUtilsXXX interface content
* It only returns the provided schema
* @param {object} schema a provided schema
* @returns {object} it returns the same schema
*/
fixExamplesByVersion(schema) {
return schema;
},
/**
* Check if request body type is binary type
* @param {string} bodyType the bodyType provided in a request body content
* @param {object} contentObj The request body content provided in spec
* @returns {boolean} Returns true if content is a binary type
*/
isBinaryContentType (bodyType, contentObj) {
return bodyType &&
!_.isEmpty(_.get(contentObj, [bodyType, 'schema'])) &&
contentObj[bodyType].schema.type === 'string' &&
contentObj[bodyType].schema.format === 'binary';
},
getOuterPropsIfIsSupported() {
return undefined;
},
addOuterPropsToRefSchemaIfIsSupported(refSchema) {
return refSchema;
},
inputValidation: inputValidationSwagger
};

View File

@@ -0,0 +1,35 @@
const Swagger2OpenAPI = require('swagger2openapi'),
{ isSwagger } = require('../common/versionUtils');
module.exports = {
/**
* Converts a Swagger 2.0 API definition into an OpenAPI 3.0 specification
* @param {Object} concreteUtils Concrete schema utils according to the specification version
* @param {object} parsedSwagger Parsed Swagger spec
* @param {function} convertExecution Function to perform the OAS-PM convertion after the Spec convertion
* @return {Object} {error, newOpenapi} The new open api spec or error if there was an error in the process
*/
convertToOAS30IfSwagger: function(concreteUtils, parsedSwagger, convertExecution) {
if (isSwagger(concreteUtils.version)) {
Swagger2OpenAPI.convertObj(
parsedSwagger,
{
fatal: false,
patch: true,
anchors: true,
warnOnly: true
},
(error, newOpenapi) => {
if (error) {
return convertExecution(error);
}
return convertExecution(null, newOpenapi.openapi);
}
);
}
else {
return convertExecution(null, parsedSwagger);
}
}
};

415
package-lock.json generated
View File

@@ -329,6 +329,11 @@
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
} }
}, },
"@exodus/schemasafe": {
"version": "1.0.0-rc.6",
"resolved": "https://registry.npmjs.org/@exodus/schemasafe/-/schemasafe-1.0.0-rc.6.tgz",
"integrity": "sha512-dDnQizD94EdBwEj/fh3zPRa/HWCS9O5au2PuHhZBbuM3xWHxuaKzPBOEWze7Nn0xW68MIpZ7Xdyn1CoCpjKCuQ=="
},
"@istanbuljs/load-nyc-config": { "@istanbuljs/load-nyc-config": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
@@ -413,10 +418,9 @@
} }
}, },
"ansi-regex": { "ansi-regex": {
"version": "4.1.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
"dev": true
}, },
"ansi-styles": { "ansi-styles": {
"version": "3.2.1", "version": "3.2.1",
@@ -555,6 +559,11 @@
"get-intrinsic": "^1.0.2" "get-intrinsic": "^1.0.2"
} }
}, },
"call-me-maybe": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz",
"integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms="
},
"callsites": { "callsites": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
@@ -674,12 +683,6 @@
"wrap-ansi": "^6.2.0" "wrap-ansi": "^6.2.0"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true
},
"string-width": { "string-width": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
@@ -987,6 +990,11 @@
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
"dev": true "dev": true
}, },
"es6-promise": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
"integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM="
},
"escalade": { "escalade": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
@@ -1602,6 +1610,12 @@
"through": "^2.3.6" "through": "^2.3.6"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"dev": true
},
"lodash": { "lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
@@ -2138,6 +2152,12 @@
"yargs-unparser": "1.6.0" "yargs-unparser": "1.6.0"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"dev": true
},
"cliui": { "cliui": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
@@ -2361,6 +2381,14 @@
} }
} }
}, },
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
}
},
"node-fetch-h2": { "node-fetch-h2": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/node-fetch-h2/-/node-fetch-h2-2.3.0.tgz", "resolved": "https://registry.npmjs.org/node-fetch-h2/-/node-fetch-h2-2.3.0.tgz",
@@ -2378,6 +2406,14 @@
"process-on-spawn": "^1.0.0" "process-on-spawn": "^1.0.0"
} }
}, },
"node-readfiles": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/node-readfiles/-/node-readfiles-0.2.0.tgz",
"integrity": "sha1-271K8SE04uY1wkXvk//Pb2BnOl0=",
"requires": {
"es6-promise": "^3.2.1"
}
},
"node-releases": { "node-releases": {
"version": "1.1.71", "version": "1.1.71",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz",
@@ -2464,6 +2500,16 @@
"fast-safe-stringify": "^2.0.7" "fast-safe-stringify": "^2.0.7"
} }
}, },
"oas-linter": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/oas-linter/-/oas-linter-3.2.2.tgz",
"integrity": "sha512-KEGjPDVoU5K6swgo9hJVA/qYGlwfbFx+Kg2QB/kd7rzV5N8N5Mg6PlsoCMohVnQmo+pzJap/F610qTodKzecGQ==",
"requires": {
"@exodus/schemasafe": "^1.0.0-rc.2",
"should": "^13.2.1",
"yaml": "^1.10.0"
}
},
"oas-resolver-browser": { "oas-resolver-browser": {
"version": "2.5.6", "version": "2.5.6",
"resolved": "https://registry.npmjs.org/oas-resolver-browser/-/oas-resolver-browser-2.5.6.tgz", "resolved": "https://registry.npmjs.org/oas-resolver-browser/-/oas-resolver-browser-2.5.6.tgz",
@@ -2477,11 +2523,6 @@
"yargs": "^17.0.1" "yargs": "^17.0.1"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
},
"ansi-styles": { "ansi-styles": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
@@ -2557,6 +2598,128 @@
} }
} }
}, },
"oas-schema-walker": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/oas-schema-walker/-/oas-schema-walker-1.1.5.tgz",
"integrity": "sha512-2yucenq1a9YPmeNExoUa9Qwrt9RFkjqaMAA1X+U7sbb0AqBeTIdMHky9SQQ6iN94bO5NW0W4TRYXerG+BdAvAQ=="
},
"oas-validator": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/oas-validator/-/oas-validator-5.0.8.tgz",
"integrity": "sha512-cu20/HE5N5HKqVygs3dt94eYJfBi0TsZvPVXDhbXQHiEityDN+RROTleefoKRKKJ9dFAF2JBkDHgvWj0sjKGmw==",
"requires": {
"call-me-maybe": "^1.0.1",
"oas-kit-common": "^1.0.8",
"oas-linter": "^3.2.2",
"oas-resolver": "^2.5.6",
"oas-schema-walker": "^1.1.5",
"reftools": "^1.1.9",
"should": "^13.2.1",
"yaml": "^1.10.0"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"oas-resolver": {
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/oas-resolver/-/oas-resolver-2.5.6.tgz",
"integrity": "sha512-Yx5PWQNZomfEhPPOphFbZKi9W93CocQj18NlD2Pa4GWZzdZpSJvYwoiuurRI7m3SpcChrnO08hkuQDL3FGsVFQ==",
"requires": {
"node-fetch-h2": "^2.3.0",
"oas-kit-common": "^1.0.8",
"reftools": "^1.1.9",
"yaml": "^1.10.0",
"yargs": "^17.0.1"
}
},
"reftools": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/reftools/-/reftools-1.1.9.tgz",
"integrity": "sha512-OVede/NQE13xBQ+ob5CKd5KyeJYU2YInb1bmV4nRoOfquZPkAkxuOXicSe1PvqIuZZ4kD13sPKBbR7UFDmli6w=="
},
"string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"requires": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
}
},
"strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"requires": {
"ansi-regex": "^5.0.1"
}
},
"wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
},
"yargs": {
"version": "17.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz",
"integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==",
"requires": {
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.3",
"y18n": "^5.0.5",
"yargs-parser": "^21.0.0"
}
},
"yargs-parser": {
"version": "21.0.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz",
"integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg=="
}
}
},
"object-inspect": { "object-inspect": {
"version": "1.10.3", "version": "1.10.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz",
@@ -2987,6 +3150,54 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true "dev": true
}, },
"should": {
"version": "13.2.3",
"resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz",
"integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==",
"requires": {
"should-equal": "^2.0.0",
"should-format": "^3.0.3",
"should-type": "^1.4.0",
"should-type-adaptors": "^1.0.1",
"should-util": "^1.0.0"
}
},
"should-equal": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz",
"integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==",
"requires": {
"should-type": "^1.4.0"
}
},
"should-format": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz",
"integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=",
"requires": {
"should-type": "^1.3.0",
"should-type-adaptors": "^1.0.1"
}
},
"should-type": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz",
"integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM="
},
"should-type-adaptors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz",
"integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==",
"requires": {
"should-type": "^1.3.0",
"should-util": "^1.0.0"
}
},
"should-util": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz",
"integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g=="
},
"sigmund": { "sigmund": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
@@ -3073,11 +3284,6 @@
"strip-ansi": "^6.0.1" "strip-ansi": "^6.0.1"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
},
"strip-ansi": { "strip-ansi": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
@@ -3118,9 +3324,9 @@
}, },
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
"version": "3.0.0", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==",
"dev": true "dev": true
} }
} }
@@ -3146,6 +3352,126 @@
"has-flag": "^3.0.0" "has-flag": "^3.0.0"
} }
}, },
"swagger2openapi": {
"version": "7.0.8",
"resolved": "https://registry.npmjs.org/swagger2openapi/-/swagger2openapi-7.0.8.tgz",
"integrity": "sha512-upi/0ZGkYgEcLeGieoz8gT74oWHA0E7JivX7aN9mAf+Tc7BQoRBvnIGHoPDw+f9TXTW4s6kGYCZJtauP6OYp7g==",
"requires": {
"call-me-maybe": "^1.0.1",
"node-fetch": "^2.6.1",
"node-fetch-h2": "^2.3.0",
"node-readfiles": "^0.2.0",
"oas-kit-common": "^1.0.8",
"oas-resolver": "^2.5.6",
"oas-schema-walker": "^1.1.5",
"oas-validator": "^5.0.8",
"reftools": "^1.1.9",
"yaml": "^1.10.0",
"yargs": "^17.0.1"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"oas-resolver": {
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/oas-resolver/-/oas-resolver-2.5.6.tgz",
"integrity": "sha512-Yx5PWQNZomfEhPPOphFbZKi9W93CocQj18NlD2Pa4GWZzdZpSJvYwoiuurRI7m3SpcChrnO08hkuQDL3FGsVFQ==",
"requires": {
"node-fetch-h2": "^2.3.0",
"oas-kit-common": "^1.0.8",
"reftools": "^1.1.9",
"yaml": "^1.10.0",
"yargs": "^17.0.1"
}
},
"reftools": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/reftools/-/reftools-1.1.9.tgz",
"integrity": "sha512-OVede/NQE13xBQ+ob5CKd5KyeJYU2YInb1bmV4nRoOfquZPkAkxuOXicSe1PvqIuZZ4kD13sPKBbR7UFDmli6w=="
},
"string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"requires": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
}
},
"strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"requires": {
"ansi-regex": "^5.0.1"
}
},
"wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
},
"yargs": {
"version": "17.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz",
"integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==",
"requires": {
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.3",
"y18n": "^5.0.5",
"yargs-parser": "^21.0.0"
}
},
"yargs-parser": {
"version": "21.0.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz",
"integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg=="
}
}
},
"table": { "table": {
"version": "5.4.5", "version": "5.4.5",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.5.tgz", "resolved": "https://registry.npmjs.org/table/-/table-5.4.5.tgz",
@@ -3170,6 +3496,12 @@
"uri-js": "^4.2.2" "uri-js": "^4.2.2"
} }
}, },
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"dev": true
},
"emoji-regex": { "emoji-regex": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
@@ -3263,6 +3595,11 @@
"is-number": "^7.0.0" "is-number": "^7.0.0"
} }
}, },
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"tslib": { "tslib": {
"version": "1.10.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
@@ -3363,6 +3700,20 @@
"resolved": "https://registry.npmjs.org/validate.io-number/-/validate.io-number-1.0.3.tgz", "resolved": "https://registry.npmjs.org/validate.io-number/-/validate.io-number-1.0.3.tgz",
"integrity": "sha1-9j/+2iSL8opnqNSODjtGGhZluvg=" "integrity": "sha1-9j/+2iSL8opnqNSODjtGGhZluvg="
}, },
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"which": { "which": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@@ -3435,12 +3786,6 @@
"strip-ansi": "^6.0.0" "strip-ansi": "^6.0.0"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true
},
"ansi-styles": { "ansi-styles": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
@@ -3539,12 +3884,6 @@
"yargs-parser": "^18.1.2" "yargs-parser": "^18.1.2"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true
},
"string-width": { "string-width": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
@@ -3588,6 +3927,12 @@
"yargs": "^13.3.0" "yargs": "^13.3.0"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"dev": true
},
"cliui": { "cliui": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",

View File

@@ -126,6 +126,7 @@
"oas-resolver-browser": "2.5.6", "oas-resolver-browser": "2.5.6",
"path-browserify": "1.0.1", "path-browserify": "1.0.1",
"postman-collection": "4.0.0", "postman-collection": "4.0.0",
"swagger2openapi": "7.0.8",
"yaml": "1.10.2" "yaml": "1.10.2"
}, },
"author": "Postman Labs <help@getpostman.com>", "author": "Postman Labs <help@getpostman.com>",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,231 @@
{
"swagger": "2.0",
"info": {
"title": "Swagger test",
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version": "1.0.0",
"not_title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"email": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.io",
"basePath": "/v2",
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "store",
"description": "Operations about user"
},
{
"name": "user",
"description": "Access to Petstore orders",
"externalDocs": {
"description": "Find out more about our store",
"url": "http://swagger.io"
}
}
],
"schemes": [
"http"
],
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
"flow": "implicit",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
},
"api_key": {
"type": "apiKey",
"name": "api_key_param",
"in": "query"
}
},
"definitions": {
"Order": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"petId": {
"type": "integer",
"format": "int64"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"shipDate": {
"type": "string",
"format": "date-time"
},
"status": {
"type": "string",
"description": "Order Status",
"enum": [
"placed",
"approved",
"delivered"
]
},
"complete": {
"type": "boolean"
}
},
"xml": {
"name": "Order"
}
},
"User": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"userStatus": {
"type": "integer",
"format": "int32",
"description": "User Status"
}
},
"xml": {
"name": "User"
}
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Category"
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Tag"
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"xml": {
"name": "photoUrl",
"wrapped": true
},
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"xml": {
"name": "tag",
"wrapped": true
},
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold"
]
}
},
"xml": {
"name": "Pet"
}
},
"ApiResponse": {
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
},
"xml": {
"name": "##default"
}
}
},
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
swagger: "2.0"
info:
$ref: ./info.yaml
host: api.example.com
basePath: /v1
schemes:
- https
paths:
$ref: ./paths.yaml

View File

@@ -0,0 +1,3 @@
title: Sample API
description: API description in Markdown.
version: 1.0.0

View File

@@ -0,0 +1,9 @@
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
produces:
- application/json
responses:
200:
description: OK

View File

@@ -0,0 +1,4 @@
type: object
properties:
name:
type: string

View File

@@ -0,0 +1,2 @@
User:
$ref: ./User.yaml

View File

@@ -0,0 +1,7 @@
swagger: '2.0'
info:
$ref: ./info/index.yaml
paths:
$ref: ./paths/index.yaml
definitions:
$ref: ./definitions/index.yaml

View File

@@ -0,0 +1,7 @@
swagger: '2.0'
info:
$ref: ./info/index1.yaml
paths:
$ref: ./paths/index.yaml
definitions:
$ref: ./definitions/index.yaml

View File

@@ -0,0 +1,2 @@
version: 0.0.0
title: Simple API

View File

@@ -0,0 +1,2 @@
version: 0.0.0
title: Simple API

View File

@@ -0,0 +1,8 @@
get:
responses:
200:
description: OK
schema:
$ref: '../definitions/User.yaml'
required:
- name

View File

@@ -0,0 +1,4 @@
get:
responses:
200:
description: OK

View File

@@ -0,0 +1,4 @@
/foo:
$ref: ./foo.yaml
/bar:
$ref: ./bar.yaml

View File

@@ -0,0 +1,10 @@
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,9 @@
type: object
allOf:
- $ref: 'Pet.yaml'
- required:
- name
properties:
description:
type: integer
format: int64

View File

@@ -0,0 +1,12 @@
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string

View File

@@ -0,0 +1,16 @@
tagsParam:
name: tags
in: query
description: tags to filter by
required: false
type: array
collectionFormat: csv
items:
type: string
limitsParam:
name: limit
in: query
description: maximum number of results to return
required: false
type: integer
format: int32

View File

@@ -0,0 +1,100 @@
swagger: "2.0"
info:
version: 1.0.0
title: Swagger Petstore
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
termsOfService: http://swagger.io/terms/
contact:
name: Swagger API Team
email: apiteam@swagger.io
url: http://swagger.io
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
host: petstore.swagger.io
basePath: /api
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/pets:
get:
description: |
Returns all pets from the system that the user has access to
Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.
operationId: findPets
parameters:
- $ref: 'parameters.yaml#/tagsParam'
- $ref: 'parameters.yaml#/limitsParam'
responses:
"200":
description: pet response
schema:
type: array
items:
$ref: 'Pet.yaml'
default:
description: unexpected error
schema:
$ref: '../common/Error.yaml'
post:
description: Creates a new pet in the store. Duplicates are allowed
operationId: addPet
parameters:
- name: pet
in: body
description: Pet to add to the store
required: true
schema:
$ref: 'NewPet.yaml'
responses:
"200":
description: pet response
schema:
$ref: 'Pet.yaml'
default:
description: unexpected error
schema:
$ref: '../common/Error.yaml'
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
parameters:
- name: id
in: path
description: ID of pet to fetch
required: true
type: integer
format: int64
responses:
"200":
description: pet response
schema:
$ref: 'Pet.yaml'
default:
description: unexpected error
schema:
$ref: '../common/Error.yaml'
delete:
description: deletes a single pet based on the ID supplied
operationId: deletePet
parameters:
- name: id
in: path
description: ID of pet to delete
required: true
type: integer
format: int64
responses:
"204":
description: pet deleted
default:
description: unexpected error
schema:
$ref: '../common/Error.yaml'

View File

@@ -0,0 +1,17 @@
properties:
offset:
type: integer
format: int32
description: Position in pagination.
limit:
type: integer
format: int32
description: Number of items to retrieve (100 max).
count:
type: integer
format: int32
description: Total number of items available.
history:
type: array
items:
$ref: '#/definitions/Activity'

View File

@@ -0,0 +1,4 @@
properties:
uuid:
type: string
description: Unique identifier for the activity

View File

@@ -0,0 +1,8 @@
properties:
code:
type: integer
format: int32
message:
type: string
fields:
type: string

View File

@@ -0,0 +1,22 @@
properties:
product_id:
type: string
description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles
currency_code:
type: string
description: "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code."
display_name:
type: string
description: Display name of product.
estimate:
type: string
description: Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or "Metered" for TAXI.
low_estimate:
type: number
description: Lower bound of the estimated price.
high_estimate:
type: number
description: Upper bound of the estimated price.
surge_multiplier:
type: number
description: Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier.

View File

@@ -0,0 +1,16 @@
properties:
product_id:
type: string
description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles.
description:
type: string
description: Description of product.
display_name:
type: string
description: Display name of product.
capacity:
type: integer
description: Capacity of product. For example, 4 people.
image:
type: string
description: Image URL representing the product.

View File

@@ -0,0 +1,6 @@
properties:
products:
description: Contains the list of products
type: array
items:
$ref: "#/definitions/Product"

View File

@@ -0,0 +1,16 @@
properties:
first_name:
type: string
description: First name of the Uber user.
last_name:
type: string
description: Last name of the Uber user.
email:
type: string
description: Email address of the Uber user
picture:
type: string
description: Image URL of the Uber user.
promo_code:
type: string
description: Promo code of the Uber user.

View File

@@ -0,0 +1,186 @@
swagger: "2.0"
info:
title: Uber API
description: Move your app forward with the Uber API
version: "1.0.0"
host: api.uber.com
schemes:
- https
basePath: /v1
securityDefinitions:
apikey:
type: apiKey
name: server_token
in: query
produces:
- application/json
paths:
/products:
get:
summary: Product Types
description: The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.
parameters:
- name: latitude
in: query
description: Latitude component of location.
required: true
type: number
format: double
- name: longitude
in: query
description: Longitude component of location.
required: true
type: number
format: double
security:
- apikey: []
tags:
- Products
responses:
"200":
description: An array of products
schema:
type: array
items:
$ref: '#/definitions/Product'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/estimates/price:
get:
summary: Price Estimates
description: The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.<br><br>The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier.
parameters:
- name: start_latitude
in: query
description: Latitude component of start location.
required: true
type: number
format: double
- name: start_longitude
in: query
description: Longitude component of start location.
required: true
type: number
format: double
- name: end_latitude
in: query
description: Latitude component of end location.
required: true
type: number
format: double
- name: end_longitude
in: query
description: Longitude component of end location.
required: true
type: number
format: double
tags:
- Estimates
responses:
"200":
description: An array of price estimates by product
schema:
type: array
items:
$ref: '#/definitions/PriceEstimate'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/estimates/time:
get:
summary: Time Estimates
description: The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs.
parameters:
- name: start_latitude
in: query
description: Latitude component of start location.
required: true
type: number
format: double
- name: start_longitude
in: query
description: Longitude component of start location.
required: true
type: number
format: double
- name: customer_uuid
in: query
type: string
format: uuid
description: Unique customer identifier to be used for experience customization.
- name: product_id
in: query
type: string
description: Unique identifier representing a specific product for a given latitude & longitude.
tags:
- Estimates
responses:
"200":
description: An array of products
schema:
type: array
items:
$ref: '#/definitions/Product'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/me:
get:
summary: User Profile
description: The User Profile endpoint returns information about the Uber user that has authorized with the application.
tags:
- User
responses:
"200":
description: Profile information for a user
schema:
$ref: '#/definitions/Profile'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/history:
get:
summary: User Activity
description: The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.<br><br>The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary.
parameters:
- name: offset
in: query
type: integer
format: int32
description: Offset the list of returned results by this amount. Default is zero.
- name: limit
in: query
type: integer
format: int32
description: Number of items to retrieve. Default is 5, maximum is 100.
tags:
- User
responses:
"200":
description: History information for the given user
schema:
$ref: '#/definitions/Activities'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
definitions:
Product:
$ref: ./definitions/Product.yaml
ProductList:
$ref: ./definitions/ProductList.yaml
PriceEstimate:
$ref: ./definitions/PriceEstimate.yaml
Profile:
$ref: ./definitions/Profile.yaml
Activity:
$ref: ./definitions/Activity.yaml
Activities:
$ref: ./definitions/Activities.yaml
Error:
$ref: ./definitions/Error.yaml

View File

@@ -0,0 +1,151 @@
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"license": {
"name": "MIT"
}
},
"host": "petstore.swagger.io",
"basePath": "/v1",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/pets": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false
}
],
"responses": {
"200": {
"description": "An paged array of pets",
"headers": {
"x-next": {
"type": "string",
"description": "A link to the next page of responses"
}
},
"schema": {
"$ref": "#/definitions/Pets"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"tags": [
"pets"
],
"responses": {
"201": {
"description": "Null response"
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/pets/{petId}": {
"get": {
"summary": "Info for a specific pet",
"operationId": "showPetById",
"tags": [
"pets"
],
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"description": "The id of the pet to retrieve",
"type": "string"
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"schema": {
"$ref": "#/definitions/Pets"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Pets": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
{
"swagger": "2.0",
"info": {
"description": "My API",
"version": "1.0.0",
"title": "My API",
"termsOfService": "http://www.domain.com",
"contact": {
"name": "support@domain.com"
}
},
"basePath": "/",
"schemes": [
"http"
],
"paths": {
"Authorization/LoginAPI": {
"post": {
"summary": "Authenticates you to the system and produces a session token that will be used for future calls",
"description": "",
"operationId": "LoginAPI",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"parameters": [{
"in": "formData",
"name": "UserName",
"description": "Login Username",
"required": true,
"type": "string",
"default": "Zaphod"
}, {
"in": "formData",
"name": "Password",
"description": "Password",
"required": true,
"type": "string"
}],
"responses": {
"200": {
"description": "API Response with session ID if login is allowed",
"schema": {
"$ref": "#/definitions/Authorization"
}
}
}
}
}
}
}

View File

@@ -0,0 +1,379 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"email": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.io",
"basePath": "/v2",
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "store",
"description": "Operations about user"
},
{
"name": "user",
"description": "Access to Petstore orders",
"externalDocs": {
"description": "Find out more about our store",
"url": "http://swagger.io"
}
}
],
"schemes": [
"http"
],
"paths": {
"/pet/{petId}": {
"get": {
"tags": [
"pet"
],
"summary": "Find pet by ID",
"description": "Returns a single pet",
"operationId": "getPetById",
"consumes": [
"application/xml",
"application/json",
"application/x-www-form-urlencoded"
],
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to return",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
}
},
"security": [
{
"api_key": []
},
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"post": {
"tags": [
"pet"
],
"summary": "Updates a pet in the store with form data",
"description": "",
"operationId": "updatePetWithForm",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be updated",
"required": true,
"type": "string"
},
{
"name": "name",
"in": "formData",
"description": "Updated name of the pet",
"required": false,
"type": "string"
},
{
"name": "status",
"in": "formData",
"description": "Updated status of the pet",
"required": false,
"type": "string"
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"delete": {
"tags": [
"pet"
],
"summary": "Deletes a pet",
"description": "",
"operationId": "deletePet",
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"name": "api_key",
"in": "header",
"description": "",
"required": false,
"type": "string"
},
{
"name": "petId",
"in": "path",
"description": "Pet id to delete",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"400": {
"description": "Invalid pet value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
"flow": "implicit",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
},
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
}
},
"definitions": {
"Order": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"petId": {
"type": "integer",
"format": "int64"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"shipDate": {
"type": "string",
"format": "date-time"
},
"status": {
"type": "string",
"description": "Order Status",
"enum": [
"placed",
"approved",
"delivered"
]
},
"complete": {
"type": "boolean"
}
},
"xml": {
"name": "Order"
}
},
"User": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"userStatus": {
"type": "integer",
"format": "int32",
"description": "User Status"
}
},
"xml": {
"name": "User"
}
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Category"
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Tag"
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"xml": {
"name": "photoUrl",
"wrapped": true
},
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"xml": {
"name": "tag",
"wrapped": true
},
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold"
]
}
},
"xml": {
"name": "Pet"
}
},
"ApiResponse": {
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
},
"xml": {
"name": "##default"
}
}
},
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
}
}

View File

@@ -0,0 +1,48 @@
{
"swagger": "2.0",
"info": {
"description": "My API",
"version": "1.0.0",
"title": "Awesome Pets API",
"termsOfService": "http://www.domain.com",
"contact": {
"name": "support@domain.com"
}
},
"basePath": "/",
"schemes": [
"http"
],
"paths": {
"/owner/{ownerId}/pet/{petId}": {
"post": {
"summary": "Find pets belonging to a owner",
"description": "",
"operationId": "findPetsOfOwners",
"parameters": [{
"in": "path",
"name": "ownerId",
"description": "Owner Id",
"required": true,
"type": "integer",
"default": "42"
}, {
"in": "path",
"name": "petId",
"description": "Pet Id",
"required": true,
"type": "integer"
}],
"responses": {
"200": {
"description": "Pet found successfully.",
"schema": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
}

View File

@@ -0,0 +1,54 @@
{
"swagger": "2.0",
"info": {
"description": "My API",
"version": "1.0.0",
"title": "My API",
"termsOfService": "http://www.domain.com",
"contact": {
"name": "support@domain.com"
}
},
"basePath": "/",
"schemes": [
"http"
],
"paths": {
"Authorization/LoginAPI": {
"post": {
"summary": "Authenticates you to the system and produces a session token that will be used for future calls",
"description": "",
"operationId": "LoginAPI",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"parameters": [{
"in": "formData",
"name": "UserName",
"description": "Login Username",
"required": true,
"type": "string"
}, {
"in": "formData",
"name": "Password",
"description": "Password",
"required": true,
"type": "string"
}],
"responses": {
"200": {
"description": "API Response with session ID if login is allowed",
"schema": {
"$ref": "#/definitions/Authorization"
}
}
}
}
}
}
}

View File

@@ -0,0 +1,29 @@
{
"swagger": "2.0",
"info": {
"title": "Simple API overview",
"version": "v2"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 300 response"
},
"300": {
"description": "200 300 response"
}
}
}
}
},
"consumes": [
"application/json"
]
}

View File

@@ -0,0 +1,219 @@
{
"swagger": "2.0",
"info": {
"title": "API Gateway / Cognito Sample API",
"description": "Pet store sample that uses Cognito Developer Authenticated Identities to generate credentials through a Java Lambda Function",
"version": "1.0.0"
},
"host": "execute-api.us-east-1.amazonaws.com",
"schemes": [
"https"
],
"basePath": "/",
"produces": [
"application/json"
],
"paths": {
"/users": {
"post": {
"summary": "Registers a new user",
"description": "Creates a new user in the DynamoDB backend database and returns a set \nof temporary credentials to sign future requests.\n",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "NewUser",
"in": "body",
"description": "New user details.",
"schema": {
"$ref": "#/definitions/User"
}
}
],
"tags": [
"Auth"
],
"x-postman-meta": {
"currentHelper": "awsSigV4",
"helperAttributes": {
"accessKey": "{{aws_access_key_id}}",
"secretKey": "{{aws_secret_access_key}}",
"region": "eu-west-1",
"service": "execute-api",
"saveHelper": true
}
},
"responses": {
"200": {
"description": "The username of the new user and set of temporary credentials",
"schema": {
"$ref": "#/definitions/RegisterUserResponse"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"500": {
"description": "Internal error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"definitions": {
"User": {
"properties": {
"username": {
"type": "string",
"description": "A unique username for the user"
},
"password": {
"type": "string",
"description": "A password for the new user"
}
}
},
"RegisterUserResponse": {
"properties": {
"username": {
"type": "string",
"description": "The username of the new user"
},
"identityId": {
"type": "string",
"description": "The unique identifier for the new user"
},
"token": {
"type": "string",
"description": "An OpenID token for the new user"
},
"credentials": {
"properties": {
"accessKey": {
"type": "string",
"description": "Temporary access key to sign requests"
},
"secretKey": {
"type": "string",
"description": "Temporary secret access key to sign requests"
},
"sessionToken": {
"type": "string",
"description": "Tempoarary session token"
},
"expiration": {
"type": "integer",
"description": "Expiration date of the temporary credentials in millis since 1/1/1970\n"
}
}
}
}
},
"LoginUserResponse": {
"properties": {
"identityId": {
"type": "string",
"description": "The unique identifier for the new user"
},
"token": {
"type": "string",
"description": "An OpenID token for the new user"
},
"credentials": {
"properties": {
"accessKey": {
"type": "string",
"description": "Temporary access key to sign requests"
},
"secretKey": {
"type": "string",
"description": "Temporary secret access key to sign requests"
},
"sessionToken": {
"type": "string",
"description": "Tempoarary session token"
},
"expiration": {
"type": "integer",
"description": "Expiration date of the temporary credentials in millis since 1/1/1970\n"
}
}
}
}
},
"NewPet": {
"properties": {
"petType": {
"type": "string",
"description": "Free text pet type"
},
"petName": {
"type": "string",
"description": "Free text pet name"
},
"petAge": {
"type": "integer",
"description": "Age of the new pet"
}
}
},
"NewPetResponse": {
"properties": {
"petId": {
"type": "string",
"description": "The generated unique identifier for the new pet"
}
}
},
"Pet": {
"properties": {
"petId": {
"type": "string",
"description": "The generated unique identifier for the new pet"
},
"petType": {
"type": "string",
"description": "Free text pet type"
},
"petName": {
"type": "string",
"description": "Free text pet name"
},
"petAge": {
"type": "integer",
"description": "Age of the new pet"
}
}
},
"Pets": {
"type": "array",
"items": {
"$ref": "Pet"
}
},
"Error": {
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"fields": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,219 @@
{
"swagger": "2.0",
"info": {
"title": "API Gateway / Cognito Sample API",
"description": "Pet store sample that uses Cognito Developer Authenticated Identities to generate credentials through a Java Lambda Function",
"version": "1.0.0"
},
"host": "execute-api.us-east-1.amazonaws.com",
"schemes": [
"https"
],
"basePath": "/",
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"paths": {
"/users": {
"post": {
"summary": "Registers a new user",
"description": "Creates a new user in the DynamoDB backend database and returns a set \nof temporary credentials to sign future requests.\n",
"produces": [
"text/json"
],
"parameters": [
{
"name": "NewUser",
"in": "body",
"description": "New user details.",
"schema": {
"$ref": "#/definitions/User"
}
}
],
"tags": [
"Auth"
],
"x-postman-meta": {
"currentHelper": "awsSigV4",
"helperAttributes": {
"accessKey": "{{aws_access_key_id}}",
"secretKey": "{{aws_secret_access_key}}",
"region": "eu-west-1",
"service": "execute-api",
"saveHelper": true
}
},
"responses": {
"200": {
"description": "The username of the new user and set of temporary credentials",
"schema": {
"$ref": "#/definitions/RegisterUserResponse"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"500": {
"description": "Internal error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"definitions": {
"User": {
"properties": {
"username": {
"type": "string",
"description": "A unique username for the user"
},
"password": {
"type": "string",
"description": "A password for the new user"
}
}
},
"RegisterUserResponse": {
"properties": {
"username": {
"type": "string",
"description": "The username of the new user"
},
"identityId": {
"type": "string",
"description": "The unique identifier for the new user"
},
"token": {
"type": "string",
"description": "An OpenID token for the new user"
},
"credentials": {
"properties": {
"accessKey": {
"type": "string",
"description": "Temporary access key to sign requests"
},
"secretKey": {
"type": "string",
"description": "Temporary secret access key to sign requests"
},
"sessionToken": {
"type": "string",
"description": "Tempoarary session token"
},
"expiration": {
"type": "integer",
"description": "Expiration date of the temporary credentials in millis since 1/1/1970\n"
}
}
}
}
},
"LoginUserResponse": {
"properties": {
"identityId": {
"type": "string",
"description": "The unique identifier for the new user"
},
"token": {
"type": "string",
"description": "An OpenID token for the new user"
},
"credentials": {
"properties": {
"accessKey": {
"type": "string",
"description": "Temporary access key to sign requests"
},
"secretKey": {
"type": "string",
"description": "Temporary secret access key to sign requests"
},
"sessionToken": {
"type": "string",
"description": "Tempoarary session token"
},
"expiration": {
"type": "integer",
"description": "Expiration date of the temporary credentials in millis since 1/1/1970\n"
}
}
}
}
},
"NewPet": {
"properties": {
"petType": {
"type": "string",
"description": "Free text pet type"
},
"petName": {
"type": "string",
"description": "Free text pet name"
},
"petAge": {
"type": "integer",
"description": "Age of the new pet"
}
}
},
"NewPetResponse": {
"properties": {
"petId": {
"type": "string",
"description": "The generated unique identifier for the new pet"
}
}
},
"Pet": {
"properties": {
"petId": {
"type": "string",
"description": "The generated unique identifier for the new pet"
},
"petType": {
"type": "string",
"description": "Free text pet type"
},
"petName": {
"type": "string",
"description": "Free text pet name"
},
"petAge": {
"type": "integer",
"description": "Age of the new pet"
}
}
},
"Pets": {
"type": "array",
"items": {
"$ref": "Pet"
}
},
"Error": {
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"fields": {
"type": "string"
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,370 @@
{
"swagger": "2.0",
"info": {
"title": "Uber API",
"description": "Move your app forward with the Uber API",
"version": "1.0.0"
},
"host": "api.uber.com",
"schemes": [
"https"
],
"basePath": "/v1",
"produces": [
"application/json"
],
"paths": {
"/products": {
"get": {
"summary": "Product Types",
"description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.",
"parameters": [
{
"name": "latitude",
"in": "query",
"description": "Latitude component of location.",
"required": true,
"type": "number",
"format": "double"
},
{
"name": "longitude",
"in": "query",
"description": "Longitude component of location.",
"required": true,
"type": "number",
"format": "double"
}
],
"tags": [
"Products"
],
"responses": {
"200": {
"description": "An array of products",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Product"
}
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/estimates/price": {
"get": {
"summary": "Price Estimates",
"description": "The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.<br><br>The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier.",
"parameters": [
{
"name": "start_latitude",
"in": "query",
"description": "Latitude component of start location.",
"required": true,
"type": "number",
"format": "double"
},
{
"name": "start_longitude",
"in": "query",
"description": "Longitude component of start location.",
"required": true,
"type": "number",
"format": "double"
},
{
"name": "end_latitude",
"in": "query",
"description": "Latitude component of end location.",
"required": true,
"type": "number",
"format": "double"
},
{
"name": "end_longitude",
"in": "query",
"description": "Longitude component of end location.",
"required": true,
"type": "number",
"format": "double"
}
],
"tags": [
"Estimates"
],
"responses": {
"200": {
"description": "An array of price estimates by product",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/PriceEstimate"
}
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/estimates/time": {
"get": {
"summary": "Time Estimates",
"description": "The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs.",
"parameters": [
{
"name": "start_latitude",
"in": "query",
"description": "Latitude component of start location.",
"required": true,
"type": "number",
"format": "double"
},
{
"name": "start_longitude",
"in": "query",
"description": "Longitude component of start location.",
"required": true,
"type": "number",
"format": "double"
},
{
"name": "customer_uuid",
"in": "query",
"type": "string",
"format": "uuid",
"description": "Unique customer identifier to be used for experience customization."
},
{
"name": "product_id",
"in": "query",
"type": "string",
"description": "Unique identifier representing a specific product for a given latitude & longitude."
}
],
"tags": [
"Estimates"
],
"responses": {
"200": {
"description": "An array of products",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Product"
}
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/me": {
"get": {
"summary": "User Profile",
"description": "The User Profile endpoint returns information about the Uber user that has authorized with the application.",
"tags": [
"User"
],
"responses": {
"200": {
"description": "Profile information for a user",
"schema": {
"$ref": "#/definitions/Profile"
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/history": {
"get": {
"summary": "User Activity",
"description": "The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.<br><br>The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary.",
"parameters": [
{
"name": "offset",
"in": "query",
"type": "integer",
"format": "int32",
"description": "Offset the list of returned results by this amount. Default is zero."
},
{
"name": "limit",
"in": "query",
"type": "integer",
"format": "int32",
"description": "Number of items to retrieve. Default is 5, maximum is 100."
}
],
"tags": [
"User"
],
"responses": {
"200": {
"description": "History information for the given user",
"schema": {
"$ref": "#/definitions/Activities"
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"definitions": {
"Product": {
"properties": {
"product_id": {
"type": "string",
"description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles."
},
"description": {
"type": "string",
"description": "Description of product."
},
"display_name": {
"type": "string",
"description": "Display name of product."
},
"capacity": {
"type": "string",
"description": "Capacity of product. For example, 4 people."
},
"image": {
"type": "string",
"description": "Image URL representing the product."
}
}
},
"PriceEstimate": {
"properties": {
"product_id": {
"type": "string",
"description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles"
},
"currency_code": {
"type": "string",
"description": "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code."
},
"display_name": {
"type": "string",
"description": "Display name of product."
},
"estimate": {
"type": "string",
"description": "Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or \"Metered\" for TAXI."
},
"low_estimate": {
"type": "number",
"description": "Lower bound of the estimated price."
},
"high_estimate": {
"type": "number",
"description": "Upper bound of the estimated price."
},
"surge_multiplier": {
"type": "number",
"description": "Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier."
}
}
},
"Profile": {
"properties": {
"first_name": {
"type": "string",
"description": "First name of the Uber user."
},
"last_name": {
"type": "string",
"description": "Last name of the Uber user."
},
"email": {
"type": "string",
"description": "Email address of the Uber user"
},
"picture": {
"type": "string",
"description": "Image URL of the Uber user."
},
"promo_code": {
"type": "string",
"description": "Promo code of the Uber user."
}
}
},
"Activity": {
"properties": {
"uuid": {
"type": "string",
"description": "Unique identifier for the activity"
}
}
},
"Activities": {
"properties": {
"offset": {
"type": "integer",
"format": "int32",
"description": "Position in pagination."
},
"limit": {
"type": "integer",
"format": "int32",
"description": "Number of items to retrieve (100 max)."
},
"count": {
"type": "integer",
"format": "int32",
"description": "Total number of items available."
},
"history": {
"type": "array",
"items": {
"$ref": "#/definitions/Activity"
}
}
}
},
"Error": {
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"fields": {
"type": "string"
}
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
swagger: '2.0'
info:
title: YAML anchor issue
version: '1.0'
schemes:
- https
securityDefinitions:
Bearer:
description: Authorization 'Bearer' token
in: header
name: Authorization
type: apiKey
tags:
- name: client
description: Client resources
paths:
/client:
get:
deprecated: false
summary: Query Client
produces: &ref_0
- application/json
security: &ref_1
- Bearer: []
tags: &ref_2
- client
parameters:
- &ref_5
in: query
name: page
type: integer
- &ref_6
in: query
name: pageSize
type: integer
default: 25
responses:
'200':
description: Search results
schema:
properties:
pagination: &ref_7
type: object
properties:
page:
type: integer
pageSize:
type: integer
total:
type: integer
count:
type: integer
type: object
post:
deprecated: false
summary: Create a new Client
produces: *ref_0
security: *ref_1
tags: *ref_2
responses:
'201': &ref_9
description: Created
schema:
type: object
properties:
_id:
type: string

View File

@@ -5,7 +5,9 @@ var expect = require('chai').expect,
_ = require('lodash'), _ = require('lodash'),
async = require('async'), async = require('async'),
VALID_OPENAPI_PATH = '../data/valid_openapi', VALID_OPENAPI_PATH = '../data/valid_openapi',
INVALID_OPENAPI_PATH = '../data/invalid_openapi'; INVALID_OPENAPI_PATH = '../data/invalid_openapi',
SWAGGER_20_FOLDER_YAML = '../data/valid_swagger/yaml/',
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/';
describe('CONVERT FUNCTION TESTS ', function() { describe('CONVERT FUNCTION TESTS ', function() {
// these two covers remaining part of util.js // these two covers remaining part of util.js
@@ -1140,6 +1142,121 @@ describe('CONVERT FUNCTION TESTS ', function() {
}); });
}); });
}); });
describe('Converting swagger 2.0 files', function() {
it('should convert path paramters to postman-compatible paramters', function (done) {
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger2-with-params.json'),
input = {
type: 'file',
data: fileData
};
Converter.convert(input, {}, function(err, convertResult) {
expect(err).to.be.null;
// Make sure that path params are updated and their respective default values
convertResult.output.forEach(function(element) {
expect(element.type).to.equal('collection');
expect(element.data.item[0].request.url.path.indexOf(':ownerId') > -1).to.equal(true);
expect(element.data.item[0].request.url.path.indexOf(':petId') > -1).to.equal(true);
let thisVar = element.data.item[0].request.url.variable[0];
expect(thisVar.type).to.equal('any');
expect(thisVar.value).to.equal('42');
expect(thisVar.key).to.equal('ownerId');
});
done();
});
});
it('Should convert a swagger document with YAML anchors', function(done) {
const fileData = fs.readFileSync(path.join(__dirname, SWAGGER_20_FOLDER_YAML, 'yaml_anchor.yaml'), 'utf8'),
input = {
type: 'string',
data: fileData
};
Converter.convert(input, {}, (error, result) => {
expect(error).to.be.null;
expect(result.result).to.equal(true);
expect(result.output.length).to.equal(1);
expect(result.output[0].type).to.have.equal('collection');
expect(result.output[0].data).to.have.property('info');
expect(result.output[0].data).to.have.property('item');
});
done();
});
it('must read values consumes', function (done) {
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger_aws_2.json'),
input = {
type: 'file',
data: fileData
};
Converter.convert(input, { requestName: 'url' }, (err, convertResult) => {
expect(err).to.be.null;
// Make sure that consumes and produces are processed
convertResult.output.forEach(function(element) {
expect(element.type).to.equal('collection');
expect(JSON.stringify(element.data.item[0].request.header[0])).to
.equal('{"key":"Content-Type","value":"application/json"}');
});
done();
});
});
it('should convert a swagger object which only have a root path.', function(done) {
const fileData = JSON.parse(
fs.readFileSync(path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger3.json'), 'utf8')
),
input = {
type: 'json',
data: fileData
};
Converter.convert(input, {}, (err, result) => {
expect(result.result).to.equal(true);
expect(result.output.length).to.equal(1);
expect(result.output[0].type).to.have.equal('collection');
expect(result.output[0].data).to.have.property('info');
expect(result.output[0].data).to.have.property('item');
done();
});
});
it('should name the requests based on requestNameSource parameter, value=`URL`', function (done) {
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger3.json'),
input = {
type: 'file',
data: fileData
};
Converter.convert(input, { requestNameSource: 'URL' }, (err, convertResult) => {
let request = convertResult.output[0].data.item[0].request;
expect(err).to.be.null;
expect(request.name).to.equal('{{baseUrl}}/');
done();
});
});
it('should name the requests based on requestNameSource parameter, value=`Fallback`', function (done) {
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger3.json'),
input = {
type: 'file',
data: fileData
};
Converter.convert(input, { requestNameSource: 'Fallback' }, (err, convertResult) => {
let request = convertResult.output[0].data.item[0].request;
expect(err).to.be.null;
expect(request.name).to.equal('List API versions');
done();
});
});
});
describe('requestNameSource option', function() { describe('requestNameSource option', function() {
var pathPrefix = VALID_OPENAPI_PATH + '/test1.json', var pathPrefix = VALID_OPENAPI_PATH + '/test1.json',

View File

@@ -0,0 +1,47 @@
const { expect } = require('chai'),
concreteUtils = require('../../../lib/swaggerUtils/schemaUtilsSwagger'),
fs = require('fs'),
validSwaggerFolder = './test/data/valid_swagger',
invalidSwaggerFolder = './test/data/invalid_swagger';
describe('parseSpec method', function () {
it('should return true and a parsed specification', function () {
let fileContent = fs.readFileSync(validSwaggerFolder + '/json/sampleswagger.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.true;
expect(parsedSpec.openapi.swagger).to.equal('2.0');
});
it('should return false and info must have a title message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_no_info_title.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('Title, and version fields are required for the Info Object');
});
it('should return false and swagger must have info object message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_no_info.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The Swagger specification must have an \"info\" field');
});
it('should return false and invalid version message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_wrong_swagger_version.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The value of "swagger" field must be 2.0');
});
it('should return false and no paths message', function () {
let fileContent = fs.readFileSync(invalidSwaggerFolder + '/invalid_no_paths.json', 'utf8');
const parsedSpec = concreteUtils.parseSpec(fileContent, {});
expect(parsedSpec.result).to.be.false;
expect(parsedSpec.reason).to.equal('The Swagger specification must have a "paths" field');
});
});

View File

@@ -0,0 +1,31 @@
const { convertToOAS30IfSwagger } = require('../../lib/swaggerUtils/swaggerToOpenapi'),
fs = require('fs'),
path = require('path'),
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/',
SWAGGER_20_INVALID_FOLDER_JSON = '../data/invalid_swagger/',
utils = require('../../lib/swaggerUtils/schemaUtilsSwagger'),
expect = require('chai').expect;
describe('Test swaggerToOpenapi method', function() {
it('Should convert a swagger file to an openapi', function() {
const fileSource = path.join(__dirname, SWAGGER_20_FOLDER_JSON + '/sampleswagger.json'),
fileData = fs.readFileSync(fileSource, 'utf8'),
parsedSpec = utils.parseSpec(fileData);
convertToOAS30IfSwagger(utils, parsedSpec.openapi, (error, openapi) => {
expect(error).to.be.null;
expect(openapi.openapi).to.be.equal('3.0.0');
});
});
it('Should throw an error when swagger file is not complete', function() {
const fileSource = path.join(__dirname, SWAGGER_20_INVALID_FOLDER_JSON + '/invalid_no_info.json'),
fileData = fs.readFileSync(fileSource, 'utf8'),
parsedSpec = utils.parseSpec(fileData);
convertToOAS30IfSwagger(utils, parsedSpec.openapi, (error, openapi) => {
expect(error.message).to.be.equal('Unsupported swagger/OpenAPI version: undefined');
expect(openapi).to.be.undefined;
});
});
});

View File

@@ -189,7 +189,7 @@ describe('filterOptionsByVersion method', function() {
{ {
id: 'optionC', id: 'optionC',
name: 'option C', name: 'option C',
supportedIn: ['3.1'], supportedIn: ['3.1', '2.0'],
default: 'A default value for option C' default: 'A default value for option C'
}, },
{ {
@@ -239,4 +239,39 @@ describe('filterOptionsByVersion method', function() {
return option.id; return option.id;
})).to.include.members(['optionA', 'optionB', 'optionD']); })).to.include.members(['optionA', 'optionB', 'optionD']);
}); });
it('Should return the options supported in version 2.0', function() {
const optionsMock = [
{
id: 'optionA',
name: 'option A',
supportedIn: ['2.0'],
default: 'A default value for option A'
},
{
id: 'optionB',
name: 'option B',
supportedIn: ['3.0'],
default: 'A default value for option B'
},
{
id: 'optionC',
name: 'option C',
supportedIn: ['3.1', '2.0'],
default: 'A default value for option C'
},
{
id: 'optionD',
name: 'option D',
supportedIn: ['3.0', '3.1'],
default: 'A default value for option D'
}
],
optionsFiltered = filterOptionsByVersion(optionsMock, '2.0');
expect(optionsFiltered).to.be.an('array');
expect(optionsFiltered.map((option) => {
return option.id;
})).to.include.members(['optionC', 'optionA']);
});
}); });

View File

@@ -0,0 +1,241 @@
const SchemaPack = require('../..').SchemaPack,
expect = require('chai').expect,
fs = require('fs'),
path = require('path'),
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/';
describe('SchemaPack instance creation', function() {
it('Should create an instance of SchemaPack when input is a string', function() {
const fileSource = path.join(__dirname, SWAGGER_20_FOLDER_JSON + '/sampleswagger.json'),
fileData = fs.readFileSync(fileSource, 'utf8'),
input = {
type: 'string',
data: fileData
},
schemapack = new SchemaPack(input);
expect(schemapack);
});
it('Should create an instance of SchemaPack when input is a file', function() {
const fileSource = path.join(__dirname, SWAGGER_20_FOLDER_JSON + '/sampleswagger.json'),
input = {
type: 'file',
data: fileSource
},
schemapack = new SchemaPack(input);
expect(schemapack);
});
});
describe('getMetaData method', function() {
it('Should return the provided input metadata', function() {
const fileSource = path.join(__dirname, SWAGGER_20_FOLDER_JSON + 'sampleswagger.json'),
input = {
type: 'file',
data: fileSource
},
schemapack = new SchemaPack(input);
schemapack.getMetaData((error, result) => {
expect(error).to.be.null;
expect(result.result).to.be.true;
expect(result.name).to.be.equal('Swagger Petstore');
});
});
});
describe('Convert method', function() {
it('Should convert an example file from: ', function(done) {
const fileSource = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'sampleswagger.json'),
fileData = fs.readFileSync(fileSource, 'utf8'),
input = {
type: 'string',
data: fileData
},
schemapack = new SchemaPack(input);
schemapack.convert((error, result) => {
expect(error).to.be.null;
expect(result.result).to.be.true;
});
done();
});
});
describe('Swagger 2.0 schemapack mergeAndValidate method', function() {
it('Should merge correctly the files in folder - petstore separated', function(done) {
let folderPath = path.join(__dirname, '../data/swaggerMultifile/petstore-separate-yaml'),
files = [],
array = [
{ fileName: folderPath + '/spec/swagger.yaml' },
{ fileName: folderPath + '/spec/Pet.yaml' },
{ fileName: folderPath + '/spec/parameters.yaml' },
{ fileName: folderPath + '/spec/NewPet.yaml' },
{ fileName: folderPath + '/common/Error.yaml' }
];
array.forEach((item) => {
files.push({
content: fs.readFileSync(item.fileName, 'utf8'),
fileName: item.fileName
});
});
var schema = new SchemaPack({ type: 'folder', data: files });
schema.mergeAndValidate((err, status) => {
if (err) {
expect.fail(null, null, err);
}
if (status.result) {
schema.convert((error, result) => {
if (error) {
expect.fail(null, null, err);
}
expect(result.result).to.equal(true);
expect(result.output.length).to.equal(1);
expect(result.output[0].type).to.have.equal('collection');
expect(result.output[0].data).to.have.property('info');
expect(result.output[0].data).to.have.property('item');
done();
});
}
else {
expect.fail(null, null, status.reason);
done();
}
});
});
it('Should merge correctly the files in folder - basicExample', function(done) {
let folderPath = path.join(__dirname, '../data/swaggerMultifile/basicExample'),
files = [],
array = [
{ fileName: folderPath + '/index.yaml' },
{ fileName: folderPath + '/info.yaml' },
{ fileName: folderPath + '/paths.yaml' }
];
array.forEach((item) => {
files.push({
content: fs.readFileSync(item.fileName, 'utf8'),
fileName: item.fileName
});
});
var schema = new SchemaPack({ type: 'folder', data: files });
schema.mergeAndValidate((err, status) => {
if (err) {
expect.fail(null, null, err);
}
if (status.result) {
schema.convert((error, result) => {
if (error) {
expect.fail(null, null, err);
}
expect(result.result).to.equal(true);
expect(result.output.length).to.equal(1);
expect(result.output[0].type).to.have.equal('collection');
expect(result.output[0].data).to.have.property('info');
expect(result.output[0].data.info.name).to.equal('Sample API');
expect(result.output[0].data).to.have.property('item');
expect(result.output[0].data.item[0].request.name).to.equal('Returns a list of users.');
done();
});
}
else {
expect.fail(null, null, status.reason);
done();
}
});
});
it('Should merge correctly the files in folder - uberTest', function(done) {
let folderPath = path.join(__dirname, '../data/swaggerMultifile/uberTest'),
files = [],
array = [
{ fileName: folderPath + '/index.yaml' },
{ fileName: folderPath + '/definitions/Activities.yaml' },
{ fileName: folderPath + '/definitions/Activity.yaml' },
{ fileName: folderPath + '/definitions/Error.yaml' },
{ fileName: folderPath + '/definitions/Product.yaml' },
{ fileName: folderPath + '/definitions/ProductList.yaml' },
{ fileName: folderPath + '/definitions/Profile.yaml' },
{ fileName: folderPath + '/definitions/PriceEstimate.yaml' }
];
array.forEach((item) => {
files.push({
content: fs.readFileSync(item.fileName, 'utf8'),
fileName: item.fileName
});
});
var schema = new SchemaPack({ type: 'folder', data: files });
schema.mergeAndValidate((err, status) => {
if (err) {
expect.fail(null, null, err);
}
if (status.result) {
schema.convert((error, result) => {
if (error) {
expect.fail(null, null, err);
}
expect(result.result).to.equal(true);
expect(result.output.length).to.equal(1);
expect(result.output[0].type).to.have.equal('collection');
expect(result.output[0].data).to.have.property('info');
expect(result.output[0].data).to.have.property('item');
expect(result.output[0].data.item[0].response[0].body).to.include('product_id');
expect(result.output[0].data.item[0].response[0].body).to.include('description');
expect(result.output[0].data.item[1].item[0].response[0].body).to.include('product_id');
expect(result.output[0].data.item[1].item[0].response[0].body).to.include('currency_code');
expect(result.output[0].data.item[2].response[0].body).to.include('first_name');
expect(result.output[0].data.item[2].response[0].body).to.include('last_name');
expect(result.output[0].data.item[3].response[0].body).to.include('offset');
expect(result.output[0].data.item[3].response[0].body).to.include('limit');
expect(result.output[0].data.item[0].response[1].body).to.include('code');
expect(result.output[0].data.item[0].response[1].body).to.include('message');
done();
});
}
else {
expect.fail(null, null, status.reason);
done();
}
});
});
it('Should not merge because therer are 2 root files - multifile-two-root-files', function() {
let folderPath = path.join(__dirname, '../data/swaggerMultifile/multifile-two-root-files'),
files = [],
array = [
{ fileName: folderPath + '/index.yaml' },
{ fileName: folderPath + '/index1.yaml' },
{ fileName: folderPath + '/definitions/index.yaml' },
{ fileName: folderPath + '/definitions/User.yaml' },
{ fileName: folderPath + '/info/index.yaml' },
{ fileName: folderPath + '/info/index1.yaml' },
{ fileName: folderPath + '/paths/bar.yaml' },
{ fileName: folderPath + '/paths/foo.yaml' },
{ fileName: folderPath + '/paths/index.yaml' }
];
array.forEach((item) => {
files.push({
content: fs.readFileSync(item.fileName, 'utf8'),
fileName: item.fileName
});
});
var schema = new SchemaPack({ type: 'folder', data: files });
schema.mergeAndValidate((err, status) => {
if (err) {
expect.fail(null, null, err);
}
expect(status.result).to.equal(false);
expect(status.reason).to.be.equal('More than one root file not supported.');
});
});
});