Merge pull request #558 from postmanlabs/feature/swagger20BundleSupport

Feature/swagger20 bundle support
This commit is contained in:
Erik Mendoza
2022-07-11 16:02:15 -05:00
committed by GitHub
152 changed files with 4822 additions and 520 deletions

View File

@@ -14,14 +14,15 @@ const _ = require('lodash'),
parse = require('./parse.js'), parse = require('./parse.js'),
{ ParseError } = require('./common/ParseError'), { ParseError } = require('./common/ParseError'),
Utils = require('./utils'), Utils = require('./utils'),
crypto = require('crypto'), crypto = require('crypto');
{ getBundleRulesDataByVersion } = require('./common/versionUtils');
let path = require('path'), let path = require('path'),
pathBrowserify = require('path-browserify'), pathBrowserify = require('path-browserify'),
BROWSER = 'browser', BROWSER = 'browser',
{ DFS } = require('./dfs'), { DFS } = require('./dfs'),
deref = require('./deref.js'); deref = require('./deref.js'),
{ isSwagger, getBundleRulesDataByVersion } = require('./common/versionUtils'),
CIRCULAR_REF_EXT_PROP = 'x-circularRef';
/** /**
@@ -165,17 +166,16 @@ function getContentFromTrace(content, partial) {
* @param {array} keyInComponents - The trace to the key in components * @param {array} keyInComponents - The trace to the key in components
* @param {object} components - A global components object * @param {object} components - A global components object
* @param {object} value - The value from node matched with data * @param {object} value - The value from node matched with data
* @param {string} version - The current version * @param {array} componentsKeys - The keys of the reusable component
* @returns {null} It modifies components global context * @returns {null} It modifies components global context
*/ */
function setValueInComponents(keyInComponents, components, value, version) { function setValueInComponents(keyInComponents, components, value, componentsKeys) {
const { COMPONENTS_KEYS } = getBundleRulesDataByVersion(version);
let currentPlace = components, let currentPlace = components,
target = keyInComponents[keyInComponents.length - 2], target = keyInComponents[keyInComponents.length - 2],
key = keyInComponents.length === 2 && COMPONENTS_KEYS.includes(keyInComponents[0]) ? key = keyInComponents.length === 2 && componentsKeys.includes(keyInComponents[0]) ?
keyInComponents[1] : keyInComponents[1] :
null; null;
if (COMPONENTS_KEYS.includes(keyInComponents[0])) { if (componentsKeys.includes(keyInComponents[0])) {
if (keyInComponents[0] === 'schema') { if (keyInComponents[0] === 'schema') {
keyInComponents[0] = 'schemas'; keyInComponents[0] = 'schemas';
} }
@@ -463,6 +463,24 @@ function resolveJsonPointerInlineNodes(parents, key) {
return pointer; return pointer;
} }
/**
* Finds the reference in the document context
* @param {object} documentContext The document context from root
* @param {object} mainKeyInTrace - The key to find
* @returns {string} The reference value
*/
function findReferenceByMainKeyInTraceFromContext(documentContext, mainKeyInTrace) {
let relatedRef = '',
globalRef;
globalRef = Object.values(documentContext.globalReferences).find((item) => {
return item.mainKeyInTrace === mainKeyInTrace;
});
if (globalRef) {
relatedRef = globalRef.reference;
}
return relatedRef;
}
/** /**
* Generates the components object from the documentContext data * Generates the components object from the documentContext data
* @param {object} documentContext The document context from root * @param {object} documentContext The document context from root
@@ -476,6 +494,7 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
let notInLine = Object.entries(documentContext.globalReferences).filter(([, value]) => { let notInLine = Object.entries(documentContext.globalReferences).filter(([, value]) => {
return value.keyInComponents.length !== 0; return value.keyInComponents.length !== 0;
}); });
const { COMPONENTS_KEYS } = getBundleRulesDataByVersion(version);
notInLine.forEach(([key, value]) => { notInLine.forEach(([key, value]) => {
let [, partial] = key.split(localPointer); let [, partial] = key.split(localPointer);
if (documentContext.globalReferences[key].refHasContent) { if (documentContext.globalReferences[key].refHasContent) {
@@ -483,7 +502,7 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
value.keyInComponents, value.keyInComponents,
components, components,
getContentFromTrace(documentContext.nodeContents[key], partial), getContentFromTrace(documentContext.nodeContents[key], partial),
version COMPONENTS_KEYS
); );
} }
}); });
@@ -542,7 +561,7 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
refData.keyInComponents, refData.keyInComponents,
components, components,
refData.nodeContent, refData.nodeContent,
version COMPONENTS_KEYS
); );
} }
} }
@@ -552,13 +571,17 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
}); });
return { return {
resRoot: traverseUtility(rootContent).map(function () { resRoot: traverseUtility(rootContent).map(function () {
let relatedRef = '';
if (this.circular) { if (this.circular) {
this.update({ [this.key]: '- Circular' }); relatedRef = findReferenceByMainKeyInTraceFromContext(documentContext, this.circular.key);
this.update({ $ref: relatedRef, [CIRCULAR_REF_EXT_PROP]: true });
} }
}), }),
newComponents: traverseUtility(components).map(function () { newComponents: traverseUtility(components).map(function () {
let relatedRef = '';
if (this.circular) { if (this.circular) {
this.update({ [this.key]: '- Circular' }); relatedRef = findReferenceByMainKeyInTraceFromContext(documentContext, this.circular.key);
this.update({ $ref: relatedRef, [CIRCULAR_REF_EXT_PROP]: true });
} }
}) })
}; };
@@ -567,19 +590,29 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
/** /**
* Generates the components object wrapper * Generates the components object wrapper
* @param {object} parsedOasObject The parsed root * @param {object} parsedOasObject The parsed root
* @param {string} nodesContent - The content from all nodes * @param {string} version - The current version
* @param {object} nodesContent - The nodes content
* @returns {object} The components object wrapper * @returns {object} The components object wrapper
*/ */
function generateComponentsWrapper(parsedOasObject, nodesContent = {}) { function generateComponentsWrapper(parsedOasObject, version, nodesContent = {}) {
let components = _.isNil(parsedOasObject.components) ? let components = _.isNil(parsedOasObject.components) ?
{} : {} :
parsedOasObject.components, parsedOasObject.components,
componentsAreReferenced = components.$ref !== undefined && !_.isEmpty(nodesContent); componentsAreReferenced = components.$ref !== undefined && !_.isEmpty(nodesContent);
if (isSwagger(version)) {
getBundleRulesDataByVersion(version).COMPONENTS_KEYS.forEach((property) => {
if (parsedOasObject.hasOwnProperty(property)) {
components[property] = parsedOasObject[property];
}
});
}
else if (parsedOasObject.hasOwnProperty('components')) {
if (componentsAreReferenced) { if (componentsAreReferenced) {
components = _.merge(parsedOasObject.components, nodesContent[components.$ref]); components = _.merge(parsedOasObject.components, nodesContent[components.$ref]);
delete components.$ref; delete components.$ref;
} }
}
return components; return components;
} }
@@ -640,7 +673,8 @@ module.exports = {
path = pathBrowserify; path = pathBrowserify;
} }
const initialComponents = generateComponentsWrapper( const initialComponents = generateComponentsWrapper(
specRoot.parsed.oasObject specRoot.parsed.oasObject,
version
), ),
initialMainKeys = getMainKeysFromComponents(initialComponents, version); initialMainKeys = getMainKeysFromComponents(initialComponents, version);
let algorithm = new DFS(), let algorithm = new DFS(),
@@ -664,6 +698,7 @@ module.exports = {
}); });
components = generateComponentsWrapper( components = generateComponentsWrapper(
specRoot.parsed.oasObject, specRoot.parsed.oasObject,
version,
rootContextData.nodeContents rootContextData.nodeContents
); );
finalElements = generateComponentsObject( finalElements = generateComponentsObject(

35
lib/bundleRules/spec20.js Normal file
View File

@@ -0,0 +1,35 @@
const SCHEMA_CONTAINERS = [
'schema',
'items',
'allOf',
'additionalProperties'
],
CONTAINERS = {
definitions: SCHEMA_CONTAINERS
},
DEFINITIONS = {
properties: 'definitions',
responses: 'responses'
},
INLINE = [
'examples',
'value',
'example'
],
COMPONENTS_KEYS = [
'definitions',
'parameters',
'responses',
'securityDefinitions'
],
ROOT_CONTAINERS_KEYS = COMPONENTS_KEYS;
module.exports = {
RULES_20: {
CONTAINERS,
DEFINITIONS,
COMPONENTS_KEYS,
INLINE,
ROOT_CONTAINERS_KEYS
}
};

View File

@@ -9,7 +9,8 @@ const _ = require('lodash'),
VERSION_3_1 = VERSION_31.version, VERSION_3_1 = VERSION_31.version,
fs = require('fs'), fs = require('fs'),
{ RULES_30 } = require('./../bundleRules/spec30'), { RULES_30 } = require('./../bundleRules/spec30'),
{ RULES_31 } = require('./../bundleRules/spec31'); { RULES_31 } = require('./../bundleRules/spec31'),
{ RULES_20 } = require('./../bundleRules/spec20');
/** /**
* gets the version key and the version and generates a regular expression that * gets the version key and the version and generates a regular expression that
@@ -235,10 +236,8 @@ function getSpecVersion({ type, data, specificationVersion }) {
*/ */
function getConcreteSchemaUtils({ type, data, specificationVersion }) { function getConcreteSchemaUtils({ type, data, specificationVersion }) {
const specVersion = getSpecVersion({ type, data, specificationVersion }); const specVersion = getSpecVersion({ type, data, specificationVersion });
if (!specVersion) {
return;
}
let concreteUtils = {}; let concreteUtils = {};
if (specVersion === DEFAULT_SPEC_VERSION) { if (specVersion === DEFAULT_SPEC_VERSION) {
concreteUtils = require('../30XUtils/schemaUtils30X'); concreteUtils = require('../30XUtils/schemaUtils30X');
} }
@@ -270,11 +269,7 @@ function filterOptionsByVersion(options, version) {
* @returns {boolean} True if the current spec is using swagger 2.0 spec * @returns {boolean} True if the current spec is using swagger 2.0 spec
*/ */
function isSwagger(version) { function isSwagger(version) {
let isSwagger = false; return compareVersion(version, VERSION_20.version);
if (version === VERSION_20.version) {
isSwagger = true;
}
return isSwagger;
} }
/** /**
@@ -286,7 +281,7 @@ function validateSupportedVersion(version) {
if (!version) { if (!version) {
return false; return false;
} }
let isValid = [DEFAULT_SPEC_VERSION, VERSION_3_1].find((supportedVersion) => { let isValid = [DEFAULT_SPEC_VERSION, VERSION_3_1, SWAGGER_VERSION].find((supportedVersion) => {
return compareVersion(version, supportedVersion); return compareVersion(version, supportedVersion);
}); });
return isValid !== undefined; return isValid !== undefined;
@@ -298,8 +293,12 @@ function validateSupportedVersion(version) {
* @returns {object} The bundling rules related with the spec * @returns {object} The bundling rules related with the spec
*/ */
function getBundleRulesDataByVersion(version) { function getBundleRulesDataByVersion(version) {
const is31 = compareVersion(version, VERSION_31.version); const is31 = compareVersion(version, VERSION_31.version),
if (is31) { is20 = compareVersion(version, VERSION_20.version);
if (is20) {
return RULES_20;
}
else if (is31) {
return RULES_31; return RULES_31;
} }
else { else {
@@ -308,10 +307,10 @@ function getBundleRulesDataByVersion(version) {
} }
/** /**
* Gets the version of a parsed Spec * Gets the version of a parsed Spec
* @param {object} spec The parsed openapi spec * @param {object} spec The parsed openapi spec
* @returns {object} The bundling rules related with the spec * @returns {object} The bundling rules related with the spec
*/ */
function getVersionFromSpec(spec) { function getVersionFromSpec(spec) {
if (!_.isNil(spec) && _.has(spec, 'swagger')) { if (!_.isNil(spec) && _.has(spec, 'swagger')) {
return spec.swagger; return spec.swagger;

View File

@@ -6,7 +6,7 @@ const slashes = /\//g,
escapedTilde = /~0/g, escapedTilde = /~0/g,
jsonPointerLevelSeparator = '/', jsonPointerLevelSeparator = '/',
escapedTildeString = '~0', escapedTildeString = '~0',
{ getBundleRulesDataByVersion } = require('./common/versionUtils'), { isSwagger, getBundleRulesDataByVersion } = require('./common/versionUtils'),
{ {
resolveFirstLevelChild, resolveFirstLevelChild,
resolveSecondLevelChild resolveSecondLevelChild
@@ -108,7 +108,7 @@ function getKeyInComponents(traceFromParent, mainKey, version, commonPathFromDat
* @returns {string} - the concatenated json pointer * @returns {string} - the concatenated json pointer
*/ */
function concatJsonPointer(traceFromParent, targetInRoot) { function concatJsonPointer(traceFromParent, targetInRoot) {
const traceFromParentAsString = traceFromParent.join('/'); const traceFromParentAsString = traceFromParent.join(jsonPointerLevelSeparator);
return localPointer + targetInRoot + jsonPointerLevelSeparator + traceFromParentAsString; return localPointer + targetInRoot + jsonPointerLevelSeparator + traceFromParentAsString;
} }
@@ -120,8 +120,8 @@ function concatJsonPointer(traceFromParent, targetInRoot) {
* @param {string} version - The version we are working on * @param {string} version - The version we are working on
* @returns {string} - the concatenated json pointer * @returns {string} - the concatenated json pointer
*/ */
function getJsonPointerRelationToRoot(refValue, traceFromKey) { function getJsonPointerRelationToRoot(refValue, traceFromKey, version) {
let targetInRoot = '/components'; let targetInRoot = isSwagger(version) ? '' : '/components';
if (refValue.startsWith(localPointer)) { if (refValue.startsWith(localPointer)) {
return refValue; return refValue;
} }

View File

@@ -1,116 +0,0 @@
const traverseUtility = require('traverse'),
{ DFS } = require('./dfs'),
{ jsonPointerDecodeAndReplace, isLocalRef, getEntityName } = require('./jsonPointer'),
deref = require('./deref.js');
/**
* verifies if the path has been added to the result
* @param {string} path - path to find
* @param {Array} referencesInNode - Array with the already added paths
* @returns {boolean} - wheter a node with the same path has been added
*/
function added(path, referencesInNode) {
return referencesInNode.find((reference) => { return reference.path === path; }) !== undefined;
}
/**
* Gets the path from a referenced entity
* @param {object} property - current node in process
* @returns {string} - $ref value
*/
function pathSolver(property) {
return property.$ref;
}
/**
* Gets all the $refs from an object
* @param {object} currentNode - current node in process
* @param {Function} refTypeResolver - function to resolve the ref according to type (local, external, web etc)
* @param {Function} pathSolver - function to resolve the Path
* @returns {object} - {path : $ref value}
*/
function getReferences (currentNode, refTypeResolver, pathSolver) {
let referencesInNode = [];
traverseUtility(currentNode).forEach((property) => {
if (property) {
let hasReferenceTypeKey;
hasReferenceTypeKey = Object.keys(property)
.find(
(key) => {
return refTypeResolver(property, key);
}
);
if (hasReferenceTypeKey) {
if (!added(property.$ref, referencesInNode)) {
referencesInNode.push({ path: pathSolver(property) });
}
}
}
});
return referencesInNode;
}
/**
* Locates a referenced node from the data input by path
* @param {string} referencePath - value from the $ref property
* @param {object} spec - parsed spec
* @returns {object} - Detect root files result object
*/
function findNodeFromPath(referencePath, spec) {
let found,
splitRef = referencePath.split('/');
splitRef = splitRef.slice(1).map((elem) => {
return jsonPointerDecodeAndReplace(elem);
});
found = deref._getEscaped(spec, splitRef);
return found;
}
/**
* Maps the output from get root files to detect root files
* @param {object} currentNode - current { path, content} object
* @param {object} spec - the whole parsed spec
* @returns {object} - Detect root files result object
*/
function getAdjacentAndMissing(currentNode, spec) {
let currentNodeReferences = getReferences(currentNode, isLocalRef, pathSolver),
graphAdj = [],
missingNodes = [];
currentNodeReferences.forEach((reference) => {
let referencePath = reference.path,
adjacentNode = findNodeFromPath(referencePath, spec);
if (adjacentNode) {
adjacentNode.$info = { $ref: referencePath, name: getEntityName(referencePath) };
graphAdj.push(adjacentNode);
}
else {
missingNodes.push({ $ref: referencePath });
}
});
return { graphAdj, missingNodes };
}
module.exports = {
/**
* Maps the output from get root files to detect root files
* @param {object} entityRoot - root file information
* @param {Array} spec - array of { path, content} objects
* @returns {object} - Detect root files result object
*/
getRelatedEntities: function (entityRoot, spec) {
let algorithm = new DFS(),
{ traverseOrder, missing } =
algorithm.traverse(entityRoot, (currentNode) => {
return getAdjacentAndMissing(currentNode, spec);
});
return { relatedEntities: traverseOrder, missingRelatedEntities: missing };
},
getReferences,
getAdjacentAndMissing,
isLocalRef,
findNodeFromPath,
pathSolver
};

View File

@@ -1,7 +1,7 @@
const parse = require('./parse.js'), const parse = require('./parse.js'),
traverseUtility = require('traverse'),
BROWSER = 'browser', BROWSER = 'browser',
{ DFS } = require('./dfs'), { DFS } = require('./dfs'),
{ getReferences } = require('./relatedEntities'),
{ isExtRef, removeLocalReferenceFromPath } = require('./jsonPointer'); { isExtRef, removeLocalReferenceFromPath } = require('./jsonPointer');
let path = require('path'), let path = require('path'),
pathBrowserify = require('path-browserify'); pathBrowserify = require('path-browserify');
@@ -23,6 +23,9 @@ function comparePaths(path1, path2) {
* @returns {object} - Detect root files result object * @returns {object} - Detect root files result object
*/ */
function calculatePath(parentFileName, referencePath) { function calculatePath(parentFileName, referencePath) {
if (path.isAbsolute(referencePath)) {
return referencePath;
}
let currentDirName = path.dirname(parentFileName), let currentDirName = path.dirname(parentFileName),
refDirName = path.join(currentDirName, referencePath); refDirName = path.join(currentDirName, referencePath);
return refDirName; return refDirName;
@@ -61,6 +64,44 @@ function findNodeFromPath(referencePath, allData) {
}); });
} }
/**
* verifies if the path has been added to the result
* @param {string} path - path to find
* @param {Array} referencesInNode - Array with the already added paths
* @returns {boolean} - wheter a node with the same path has been added
*/
function added(path, referencesInNode) {
return referencesInNode.find((reference) => { return reference.path === path; }) !== undefined;
}
/**
* Gets all the $refs from an object
* @param {object} currentNode - current node in process
* @param {Function} refTypeResolver - function to resolve the ref according to type (local, external, web etc)
* @param {Function} pathSolver - function to resolve the Path
* @returns {object} - {path : $ref value}
*/
function getReferences (currentNode, refTypeResolver, pathSolver) {
let referencesInNode = [];
traverseUtility(currentNode).forEach((property) => {
if (property) {
let hasReferenceTypeKey;
hasReferenceTypeKey = Object.keys(property)
.find(
(key) => {
return refTypeResolver(property, key);
}
);
if (hasReferenceTypeKey) {
if (!added(property.$ref, referencesInNode)) {
referencesInNode.push({ path: pathSolver(property) });
}
}
}
});
return referencesInNode;
}
/** /**
* Maps the output from get root files to detect root files * Maps the output from get root files to detect root files
* @param {object} currentNode - current { path, content} object * @param {object} currentNode - current { path, content} object

View File

@@ -6,7 +6,7 @@
const { ParseError } = require('./common/ParseError.js'); const { ParseError } = require('./common/ParseError.js');
const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/schemaUtilsCommon.js'), const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/schemaUtilsCommon.js'),
{ getConcreteSchemaUtils, SWAGGER_VERSION, validateSupportedVersion } = require('./common/versionUtils.js'), { getConcreteSchemaUtils, isSwagger, validateSupportedVersion } = require('./common/versionUtils.js'),
async = require('async'), async = require('async'),
sdk = require('postman-collection'), sdk = require('postman-collection'),
schemaFaker = require('../assets/json-schema-faker.js'), schemaFaker = require('../assets/json-schema-faker.js'),
@@ -4842,16 +4842,22 @@ module.exports = {
/** /**
* Maps the output for each bundled root file * Maps the output for each bundled root file
* @param {object} format - defined output format from options * @param {object} format - defined output format from options
* @param {string} parsedRootFiles - specified version of the process * @param {string} parsedRootFiles - The parsed root files
* @param {string} version - specified version of the process
* @param {object} options - a standard list of options that's globally passed around. Check options.js for more. * @param {object} options - a standard list of options that's globally passed around. Check options.js for more.
* @returns {object} - { rootFile: { path }, bundledContent } * @returns {object} - { rootFile: { path }, bundledContent }
*/ */
mapBundleOutput(format, parsedRootFiles, options = {}) { mapBundleOutput(format, parsedRootFiles, version, options = {}) {
return (contentAndComponents) => { return (contentAndComponents) => {
let bundledFile = contentAndComponents.fileContent, let bundledFile = contentAndComponents.fileContent,
bundleOutput; bundleOutput;
if (!_.isEmpty(contentAndComponents.components)) { if (isSwagger(version)) {
Object.entries(contentAndComponents.components).forEach(([key, value]) => {
bundledFile[key] = value;
});
}
else if (!_.isEmpty(contentAndComponents.components)) {
bundledFile.components = contentAndComponents.components; bundledFile.components = contentAndComponents.components;
} }
if (!format) { if (!format) {
@@ -4901,7 +4907,7 @@ module.exports = {
return bundleData; return bundleData;
}); });
let bundleData = data.map(this.mapBundleOutput(format, parsedRootFiles, options)); let bundleData = data.map(this.mapBundleOutput(format, parsedRootFiles, version, options));
return bundleData; return bundleData;
}, },
@@ -4926,7 +4932,7 @@ module.exports = {
let parsedContent = parseFileOrThrow(rootFile.content); let parsedContent = parseFileOrThrow(rootFile.content);
return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent }; return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent };
}).filter((rootWithParsedContent) => { }).filter((rootWithParsedContent) => {
let fileVersion = version === SWAGGER_VERSION ? let fileVersion = isSwagger(version) ?
rootWithParsedContent.parsed.oasObject.swagger : rootWithParsedContent.parsed.oasObject.swagger :
rootWithParsedContent.parsed.oasObject.openapi; rootWithParsedContent.parsed.oasObject.openapi;
return compareVersion(version, fileVersion); return compareVersion(version, fileVersion);
@@ -4934,8 +4940,8 @@ module.exports = {
data = toBundle ? data = toBundle ?
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat, version, options) : this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat, version, options) :
this.getRelatedFilesData(parsedRootFiles, inputData, origin); this.getRelatedFilesData(parsedRootFiles, inputData, origin);
return data;
return data;
}, },
/** /**

View File

@@ -634,7 +634,6 @@ class SchemaPack {
if (!this.hasDefinedVersion && ('content' in input.data[0])) { if (!this.hasDefinedVersion && ('content' in input.data[0])) {
return schemaUtils.mapGetRootFilesOutputToDetectRootFilesOutput([], input.specificationVersion); return schemaUtils.mapGetRootFilesOutputToDetectRootFilesOutput([], input.specificationVersion);
} }
let files = {}, let files = {},
rootFiles, rootFiles,
res, res,

View File

@@ -1,4 +1,5 @@
const _ = require('lodash');
module.exports = { module.exports = {
/** /**
@@ -8,6 +9,12 @@ module.exports = {
* @return {Object} Validation result * @return {Object} Validation result
*/ */
validateSpec: function (spec, options) { validateSpec: function (spec, options) {
if (_.isNil(spec)) {
return {
result: false,
reason: 'The Specification is null or undefined'
};
}
if (spec.swagger !== '2.0') { if (spec.swagger !== '2.0') {
return { return {
result: false, result: false,
@@ -20,7 +27,7 @@ module.exports = {
reason: 'The Swagger specification must have an "info" field' reason: 'The Swagger specification must have an "info" field'
}; };
} }
if (!(spec.info.title && spec.info.version) && !options.isFolder) { if (!(_.get(spec, 'info.title') && _.get(spec, 'info.version')) && !options.isFolder) {
return { return {
result: false, result: false,
reason: 'Title, and version fields are required for the Info Object' reason: 'Title, and version fields are required for the Info Object'

View File

@@ -0,0 +1,29 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/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,223 @@
{
"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\nNam 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.\n\nSed 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.\n",
"operationId": "findPets",
"parameters": [
{
"$ref": "#/parameters/_spec_parameters.yaml-_tagsParam"
},
{
"$ref": "#/parameters/_spec_parameters.yaml-_limitsParam"
}
],
"responses": {
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/_spec_Pet.yaml"
}
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/_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": "#/definitions/_spec_NewPet.yaml"
}
}
],
"responses": {
"200": {
"description": "pet response",
"schema": {
"$ref": "#/definitions/_spec_Pet.yaml"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/_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": "#/definitions/_spec_Pet.yaml"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/_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": "#/definitions/_common_Error.yaml"
}
}
}
}
}
},
"parameters": {
"_spec_parameters.yaml-_tagsParam": {
"name": "tags",
"in": "query",
"description": "tags to filter by",
"required": false,
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "string"
}
},
"_spec_parameters.yaml-_limitsParam": {
"name": "limit",
"in": "query",
"description": "maximum number of results to return",
"required": false,
"type": "integer",
"format": "int32"
}
},
"definitions": {
"_spec_Pet.yaml": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"_common_Error.yaml": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
},
"_spec_NewPet.yaml": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/_spec_Pet.yaml"
},
{
"required": [
"name"
],
"properties": {
"description": {
"type": "integer",
"format": "int64"
}
}
}
]
}
}
}

View File

@@ -22,23 +22,21 @@
"operationId": "findPets", "operationId": "findPets",
"responses": { "responses": {
"200": { "200": {
"description": "pet response", "description": "An paged array of pets",
"content": {
"application/json": {
"schema": { "schema": {
"type": "array", "type": "array",
"items": { "items": {
"$ref\"": "./schemas/schemas.yaml"
}
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/components/schemas/_schemas_schemas.yaml-components_schemas_ErrorDetail" "$ref": "#/components/schemas/_schemas_schemas.yaml-components_schemas_ErrorDetail"
} }
} }
} }
} }
} }
}
}
}
}, },
"components": { "components": {
"schemas": { "schemas": {
@@ -65,7 +63,8 @@
"readOnly": true, "readOnly": true,
"type": "array", "type": "array",
"items": { "items": {
"items": "- Circular" "$ref": "#/components/schemas/_schemas_schemas.yaml-components_schemas_ErrorDetail",
"x-circularRef": true
}, },
"description": "The error details." "description": "The error details."
} }

View File

@@ -12,22 +12,17 @@ info:
license: license:
name: Apache 2.0 name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html url: https://www.apache.org/licenses/LICENSE-2.0.html
paths: paths:
/pets: /pets:
get: get:
description: Returns all pets alesuada ac... description: Returns all pets alesuada ac...
operationId: findPets operationId: findPets
responses: responses:
"200": '200':
description: pet response description: An paged array of pets
content:
application/json:
schema: schema:
type: array type: array
items: items:
$ref": "./schemas/schemas.yaml"
default:
description: unexpected error
schema:
$ref: "./schemas/schemas.yaml#components/schemas/ErrorDetail" $ref: "./schemas/schemas.yaml#components/schemas/ErrorDetail"

View File

@@ -1,21 +0,0 @@
operationId: loadBalancers_remove_droplets
summary: Remove Droplets from a Load Balancer
description: |
To remove a..
requestBody:
required: true
content:
application/json:
schema:
properties:
testProp:
$ref: './test.yaml'
responses:
default:
description: ok

View File

@@ -0,0 +1,52 @@
{
"openapi": "3.0.0",
"info": {
"title": "Sample API",
"description": "Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.",
"version": "0.1.9"
},
"servers": [
{
"url": "http://api.example.com/v1",
"description": "Optional server description, e.g. Main (production) server"
},
{
"url": "http://staging-api.example.com",
"description": "Optional server description, e.g. Internal staging server for testing"
}
],
"paths": {
"/users/{userId}": {
"get": {
"summary": "Get a user by ID",
"responses": {
"200": {
"description": "A single user.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/~1schemas~1user.yaml"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"/schemas/user.yaml": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"userName": {
"type": "string"
}
}
}
}
}
}

View File

@@ -0,0 +1,32 @@
openapi: 3.0.0
info:
title: Sample API
description: >-
Optional multiline or single-line description in
[CommonMark](http://commonmark.org/help/) or HTML.
version: 0.1.9
servers:
- url: 'http://api.example.com/v1'
description: 'Optional server description, e.g. Main (production) server'
- url: 'http://staging-api.example.com'
description: 'Optional server description, e.g. Internal staging server for testing'
paths:
'/users/{userId}':
get:
summary: Get a user by ID
responses:
'200':
description: A single user.
content:
application/json:
schema:
$ref: '#/components/schemas/~1schemas~1user.yaml'
components:
schemas:
/schemas/user.yaml:
type: object
properties:
id:
type: integer
userName:
type: string

View File

@@ -0,0 +1,6 @@
headerTest:
schema:
type: integer
example: 5000
description: >-
The test header

View File

@@ -0,0 +1,26 @@
openapi: 3.0.0
info:
title: Sample API
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
version: 0.1.9
servers:
- url: http://api.example.com/v1
description: Optional server description, e.g. Main (production) server
- url: http://staging-api.example.com
description: Optional server description, e.g. Internal staging server for testing
paths:
/users/{userId}:
get:
summary: Get a user by ID
responses:
200:
description: A single user.
headers:
ratelimit-limit:
$ref: '../headers.yaml#/headerTest'
content:
application/json:
schema:
$ref: "./schemas/user.yaml"

View File

@@ -0,0 +1,6 @@
type: object
properties:
id:
type: integer
userName:
type: string

View File

@@ -0,0 +1,9 @@
type:
object
properties:
color:
type: string
weight:
type: integer
height:
type: integer

View File

@@ -0,0 +1,69 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to,",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.,",
"schema": {
"$ref": "#/definitions/_pet.yaml"
}
}
}
}
}
},
"definitions": {
"_pet.yaml": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/definitions/_additionalProperties.yaml"
}
}
},
"_additionalProperties.yaml": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"weight": {
"type": "integer"
},
"height": {
"type": "integer"
}
}
}
}
}

View File

@@ -0,0 +1,14 @@
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
additionalProperties:
$ref: "./additionalProperties.yaml"

View File

@@ -0,0 +1,20 @@
swagger: "2.0"
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
host: api.example.com
basePath: /v1
schemes:
- https
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to,
produces:
- application/json
responses:
200:
description: A list of pets.,
schema:
$ref: "./pet.yaml"

View File

@@ -0,0 +1,29 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/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,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,73 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/users": {
"get": {
"summary": "Returns a list of users.",
"description": "Optional extended description in Markdown.",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/_pet.yaml-_Pet"
}
}
}
}
}
}
},
"definitions": {
"_pet.yaml-_Pet": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"Color": {
"$ref": "#/definitions/_pet.yaml-_Color"
}
}
},
"_pet.yaml-_Color": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"uses": {
"type": "string"
},
"color": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,10 @@
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,13 @@
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
produces:
- application/json
responses:
200:
description: OK
schema:
type: array
items:
$ref: "./pet.yaml#/Pet"

View File

@@ -0,0 +1,25 @@
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Color:
$ref: "#/Color"
Color:
type: object
properties:
name:
type: string
uses:
type: string
color:
type: string

View File

@@ -0,0 +1,136 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/users": {
"get": {
"summary": "Returns a list of users.",
"description": "Optional extended description in Markdown.",
"parameters": [
{
"$ref": "#/parameters/_parameters_parameters.yaml-_Parameter1"
},
{
"$ref": "#/parameters/_parameters_parameters.yaml-_Parameter2"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/_pet.yaml-_Pet"
}
}
}
}
}
}
},
"parameters": {
"_parameters_parameters.yaml-_Parameter1": {
"name": "tags",
"in": "query",
"description": "tags to filter by",
"required": false,
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "string"
}
},
"_parameters_parameters.yaml-_Parameter2": {
"name": "limit",
"in": "query",
"description": "maximum number of results to return",
"required": false,
"type": "integer",
"format": "int32"
}
},
"definitions": {
"_pet.yaml-_Pet": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"Color": {
"$ref": "#/definitions/_pet.yaml-_Color"
},
"FavoriteFood": {
"$ref": "#/definitions/_food.yaml-_Food"
}
}
},
"_pet.yaml-_Color": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"uses": {
"type": "string"
},
"color": {
"type": "string"
}
}
},
"_food.yaml-_Food": {
"type": "object",
"properties": {
"brand": {
"$ref": "#/definitions/_food.yaml-_Brand"
},
"benefits": {
"type": "array",
"items": {
"$ref": "#/definitions/_food.yaml-_Benefit"
}
},
"cost": {
"type": "string"
}
}
},
"_food.yaml-_Brand": {
"type": "string"
},
"_food.yaml-_Benefit": {
"type": "object",
"properties": {
"benefit": {
"type": "string"
},
"detail": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,22 @@
Food:
type: object
properties:
brand:
$ref: "#/Brand"
benefits:
type: array
items:
$ref: "#/Benefit"
cost:
type: string
Brand:
type: string
Benefit:
type: object
properties:
benefit:
type: string
detail:
type: string

View File

@@ -0,0 +1,10 @@
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,16 @@
Parameter1:
name: tags
in: query
description: tags to filter by
required: false
type: array
collectionFormat: csv
items:
type: string
Parameter2:
name: limit
in: query
description: maximum number of results to return
required: false
type: integer
format: int32

View File

@@ -0,0 +1,16 @@
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
parameters:
- $ref: "./parameters/parameters.yaml#/Parameter1"
- $ref: "./parameters/parameters.yaml#/Parameter2"
produces:
- application/json
responses:
200:
description: OK
schema:
type: array
items:
$ref: "./pet.yaml#/Pet"

View File

@@ -0,0 +1,29 @@
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Color:
$ref: "#/Color"
FavoriteFood:
$ref: "./food.yaml#/Food"
Color:
type: object
properties:
name:
type: string
uses:
type: string
color:
type: string

View File

@@ -0,0 +1,76 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/users": {
"get": {
"summary": "Returns a list of users.",
"description": "Optional extended description in Markdown.",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/_pet.yaml-_Pet"
}
}
}
}
}
}
},
"definitions": {
"_pet.yaml-_Pet": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"Colors": {
"type": "array",
"items": {
"$ref": "#/definitions/_pet.yaml-_Color"
}
}
}
},
"_pet.yaml-_Color": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"uses": {
"type": "string"
},
"color": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,10 @@
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,13 @@
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
produces:
- application/json
responses:
200:
description: OK
schema:
type: array
items:
$ref: "./pet.yaml#/Pet"

View File

@@ -0,0 +1,27 @@
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Colors:
type: array
items:
$ref: "#/Color"
Color:
type: object
properties:
name:
type: string
uses:
type: string
color:
type: string

View File

@@ -0,0 +1,95 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/pets": null,
"get": {
"description": "Returns all pets from the system that the user has access to",
"operationId": "findPets",
"parameters": [
{
"$ref": "#/parameters/Parameter1"
},
{
"$ref": "#/parameters/Parameter2"
}
],
"responses": {
"200": {
"description": "pet response",
"schema": {
"$ref": "#/definitions/Pet"
}
}
}
}
},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"Color": {
"$ref": "#/definitions/_pet.yaml-_Color"
}
}
},
"_pet.yaml-_Color": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"uses": {
"type": "string"
},
"color": {
"type": "string"
}
}
}
},
"parameters": {
"Parameter1": {
"name": "tags",
"in": "query",
"description": "tags to filter by",
"required": false,
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "string"
}
},
"Parameter2": {
"name": "limit",
"in": "query",
"description": "maximum number of results to return",
"required": false,
"type": "integer",
"format": "int32"
}
}
}

View File

@@ -0,0 +1,28 @@
swagger: "2.0"
info:
$ref: ./info.yaml
host: api.example.com
basePath: /v1
schemes:
- https
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to
operationId: findPets
parameters:
- $ref: "#/parameters/Parameter1"
- $ref: "#/parameters/Parameter2"
responses:
200:
description: pet response
schema:
$ref: "#/definitions/Pet"
definitions:
Pet:
$ref: "./pet.yaml#/Pet"
parameters:
Parameter1:
$ref: "./parameters/parameters.yaml#/Parameter1"
Parameter2:
$ref: "./parameters/parameters.yaml#/Parameter2"

View File

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

View File

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

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,25 @@
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Color:
$ref: "#/Color"
Color:
type: object
properties:
name:
type: string
uses:
type: string
color:
type: string

View File

@@ -0,0 +1,72 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to,",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.,",
"schema": {
"$ref": "#/definitions/_schemas_pet.yaml"
}
}
}
}
}
},
"definitions": {
"_schemas_pet.yaml": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"favoriteFood": {
"$ref": "#/definitions/_schemas_favorite_food.yaml-_FavoriteFood"
},
"foodPrice": {
"$ref": "#/definitions/_schemas_favorite_food.yaml-_Price"
}
}
},
"_schemas_favorite_food.yaml-_FavoriteFood": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"brand": {
"type": "string"
}
}
},
"_schemas_favorite_food.yaml-_Price": {
"type": "integer"
}
}
}

View File

@@ -0,0 +1,18 @@
swagger: "2.0"
info:
$ref: ./info.yaml
host: api.example.com
basePath: /v1
schemes:
- https
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to,
produces:
- application/json
responses:
200:
description: A list of pets.,
schema:
$ref: "./schemas/pet.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,11 @@
FavoriteFood:
type: object
properties:
name:
type:
string
brand:
type:
string
Price:
type: integer

View File

@@ -0,0 +1,16 @@
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
favoriteFood:
$ref: "./favorite_food.yaml#/FavoriteFood"
foodPrice:
$ref: "./favorite_food.yaml#/Price"

View File

@@ -0,0 +1,68 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/users": {
"get": {
"summary": "Returns a list of users.",
"description": "Optional extended description in Markdown.",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/_schemas_user.yaml"
}
}
}
}
}
}
},
"definitions": {
"_schemas_user.yaml": {
"type": "object",
"properties": {
"age": {
"$ref": "#/definitions/_schemas_age.yaml"
},
"hobbies": {
"$ref": "#/definitions/_schemas_hobbies.yaml"
}
}
},
"_schemas_age.yaml": {
"type": "string"
},
"_schemas_hobbies.yaml": {
"type": "array",
"items": {
"$ref": "#/definitions/_schemas_hobby.yaml"
}
},
"_schemas_hobby.yaml": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"position": {
"type": "integer"
}
}
}
}
}

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,13 @@
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
produces:
- application/json
responses:
200:
description: OK
schema:
type: array
items:
$ref: "./schemas/user.yaml"

View File

@@ -0,0 +1 @@
type: string

View File

@@ -0,0 +1,3 @@
type: array
items:
$ref: "./hobby.yaml"

View File

@@ -1,6 +1,6 @@
type: object type: object
properties: properties:
prop1: name:
type: string type: string
prop2: position:
type: integer type: integer

View File

@@ -0,0 +1,6 @@
type: object
properties:
age:
$ref: "./age.yaml"
hobbies:
$ref: "./hobbies.yaml"

View File

@@ -0,0 +1,66 @@
{
"swagger": "2.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to,",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.,",
"schema": {
"$ref": "#/definitions/_schemas_pet.yaml"
}
}
}
}
}
},
"definitions": {
"_schemas_pet.yaml": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"favoriteFood": {
"$ref": "#/definitions/_schemas_favorite_food.yaml"
}
}
},
"_schemas_favorite_food.yaml": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"brand": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,18 @@
swagger: "2.0"
info:
$ref: ./info.yaml
host: api.example.com
basePath: /v1
schemes:
- https
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to,
produces:
- application/json
responses:
200:
description: A list of pets.,
schema:
$ref: "./schemas/pet.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,8 @@
type: object
properties:
name:
type:
string
brand:
type:
string

View File

@@ -0,0 +1,14 @@
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
favoriteFood:
$ref: "./favorite_food.yaml"

View File

@@ -0,0 +1,2 @@
application/json:
name: Puma

View File

@@ -0,0 +1,88 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"examples": {
"application/json": {
"name": "Puma"
}
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
},
"examples": {
"application/json": {
"name": "Puma"
}
}
}
}
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,57 @@
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
paths:
/pets:
get:
description: Returns all pets alesuada ac...
operationId: findPets
responses:
'200':
description: pet response
schema:
type: array
items:
$ref: '#/definitions/Pet'
examples:
$ref: "examples.yaml"
default:
description: unexpected error
schema:
$ref: '#/definitions/Error'
examples:
application/json:
$ref: "examples.yaml#/application~1json"
definitions:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,3 @@
id: 1
name: Puma
tag: Test

View File

@@ -0,0 +1,83 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
},
"example": {
"id": 1,
"name": "Puma",
"tag": "Test"
}
}
},
"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"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,54 @@
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
paths:
/pets:
get:
description: Returns all pets alesuada ac...
operationId: findPets
responses:
'200':
description: pet response
schema:
type: array
items:
$ref: '#/definitions/Pet'
example:
$ref: "example.yaml"
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
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,107 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}

View File

@@ -0,0 +1,31 @@
description: Returns all pets alesuada ac...
operationId: findPets
responses:
"200":
description: pet response
content:
application/json:
schema:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
default:
description: unexpected error
content:
application/json:
schema:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,3 @@
/pets:
get:
"$ref": "./path.yaml"

View File

@@ -0,0 +1,38 @@
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
paths:
"$ref": "./paths/paths.yaml"
definitions:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,85 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets",
"content": {
"application/json": {
"schema": {
"$ref": "#/definitions/_paths_path.yaml-_definitions_Error"
}
},
"description": "Returns all pets from the system that the user has access to,",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.,",
"schema": {
"$ref": "#/definitions/_paths_path.yaml-_definitions_Pet"
}
}
}
}
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
},
"_paths_path.yaml-_definitions_Error": {
"$ref": "#/definitions/Error"
},
"_paths_path.yaml-_definitions_Pet": {
"$ref": "#/definitions/Pet"
}
}
}

View File

@@ -0,0 +1,13 @@
description: Returns all pets
content:
application/json:
schema:
$ref: "#/definitions/Error"
description: Returns all pets from the system that the user has access to,
produces:
- application/json
responses:
200:
description: A list of pets.,
schema:
$ref: "#/definitions/Pet"

View File

@@ -0,0 +1,3 @@
/pets:
get:
"$ref": "./path.yaml"

View File

@@ -0,0 +1,38 @@
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
paths:
"$ref": "./paths/paths.yaml"
definitions:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,74 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"$ref": "#/responses/_response.yaml"
}
}
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
},
"responses": {
"_response.yaml": {
"description": "A simple string response",
"schema": {
"type": "string"
}
}
}
}

View File

@@ -0,0 +1,3 @@
description: A simple string response
schema:
type: string

View File

@@ -0,0 +1,44 @@
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
paths:
/pets:
get:
description: Returns all pets alesuada ac...
operationId: findPets
responses:
'200':
$ref: "./response.yaml"
definitions:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,22 @@
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,141 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"type": "oauth2",
"authorizationUrl": "http://swagger.io/api/oauth/dialog",
"flow": "implicit",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
},
"tags": [
{
"name": "Authorization",
"x-bx-tag": "authorization",
"x-bx-priority": true
},
{
"name": "Bx Sign",
"x-bx-tag": "sign_requests"
}
],
"responses": {
"200": {
"description": "A simple string response",
"schema": {
"type": "string"
}
},
"400": {
"description": "A simple string response from 400 code",
"schema": {
"type": "string"
}
}
}
}

View File

@@ -0,0 +1,11 @@
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

View File

@@ -0,0 +1,31 @@
description: Returns all pets alesuada ac...
operationId: findPets
responses:
"200":
description: pet response
content:
application/json:
schema:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
default:
description: unexpected error
content:
application/json:
schema:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@@ -0,0 +1,3 @@
/pets:
get:
"$ref": "./path.yaml"

View File

@@ -0,0 +1,8 @@
'200':
description: A simple string response
schema:
type: string
'400':
description: A simple string response from 400 code
schema:
type: string

View File

@@ -0,0 +1,13 @@
swagger: '2.0'
info:
$ref: './info.yaml'
paths:
"$ref": "./paths/paths.yaml"
definitions:
$ref: './definitions.yaml'
securityDefinitions:
$ref: './securitySchemes.yaml'
tags:
$ref: './tags.yaml'
responses:
$ref: './responses.yaml'

View File

@@ -0,0 +1,6 @@
type: oauth2
authorizationUrl: http://swagger.io/api/oauth/dialog
flow: implicit
scopes:
write:pets: modify pets in your account
read:pets: read your pets

View File

@@ -0,0 +1,6 @@
- name: Authorization
x-bx-tag: authorization
x-bx-priority: true
- name: Bx Sign
x-bx-tag: sign_requests

View File

@@ -0,0 +1,91 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
}
},
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"authorizationUrl": "http://swagger.io/api/oauth/dialog",
"flow": "implicit",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
}

View File

@@ -0,0 +1,55 @@
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
paths:
/pets:
get:
description: Returns all pets alesuada ac...
operationId: findPets
responses:
'200':
description: pet response
schema:
type: array
items:
$ref: '#/definitions/Pet'
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
definitions:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
securityDefinitions:
petstore_auth:
$ref: "./sschemes.yaml"

View File

@@ -0,0 +1,6 @@
type: oauth2
authorizationUrl: http://swagger.io/api/oauth/dialog
flow: implicit
scopes:
write:pets: modify pets in your account
read:pets: read your pets

View File

@@ -0,0 +1,89 @@
{
"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"
}
},
"paths": {
"/pets": {
"get": {
"description": "Returns all pets alesuada ac...",
"operationId": "findPets",
"responses": {
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"tags": [
{
"name": "Authorization",
"x-bx-tag": "authorization",
"x-bx-priority": true
},
{
"name": "Bx Sign",
"x-bx-tag": "sign_requests"
}
],
"definitions": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More