Fix resolve external references bug (#216)

This commit is contained in:
Vlad Barosan 2018-02-08 17:58:25 -08:00 коммит произвёл GitHub
Родитель 650219c51d
Коммит 237053f428
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 24 добавлений и 19 удалений

Просмотреть файл

@ -1,3 +1,6 @@
### 02/05/2018 0.4.32
- Fix bug for resolve external references introduced part of #202.
### 02/05/2018 0.4.31
- Bug fix for the fix made to resolve jshint issues in #202.

Просмотреть файл

@ -303,26 +303,28 @@ class SpecResolver {
//resolving relative swaggers.
if (result && result.definitions) {
let unresolvedDefinitions = [];
let processDefinition = (defName) => {
if (result.definitions[defName].allOf) {
let matchFound = result.definitions[defName].allOf.some((item) => {
return (!self.visitedEntities[`/definitions/${defName}`]);
});
if (matchFound) {
let slicedDefinitionRef = `/definitions/${defName}`;
let definitionObj = result.definitions[defName];
utils.setObject(self.specInJson, slicedDefinitionRef, definitionObj);
self.visitedEntities[slicedDefinitionRef] = definitionObj;
return self.resolveRelativePaths(definitionObj, docPath, 'all');
unresolvedDefinitions.push(() => {
if (result.definitions[defName].allOf) {
let matchFound = result.definitions[defName].allOf.some((item) => {
return (!self.visitedEntities[`/definitions/${defName}`]);
});
if (matchFound) {
let slicedDefinitionRef = `/definitions/${defName}`;
let definitionObj = result.definitions[defName];
utils.setObject(self.specInJson, slicedDefinitionRef, definitionObj);
self.visitedEntities[slicedDefinitionRef] = definitionObj;
return self.resolveRelativePaths(definitionObj, docPath, 'all');
}
return Promise.resolve();
}
return Promise.resolve();
}
});
};
for (const defName of utils.getKeys(result.definitions)) {
unresolvedDefinitions.push(processDefinition(defName));
processDefinition(defName);
}
return utils.executePromisesSequentially(unresolvedDefinitions);
}
return Promise.resolve();

6
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.4.31",
"version": "0.4.32",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -2395,7 +2395,7 @@
"tunnel": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz",
"integrity": "sha512-gj5sdqherx4VZKMcBA4vewER7zdK25Td+z1npBqpbDys4eJrLx+SlYjJvq1bDXs2irkuJM5pf8ktaEQVipkrbA=="
"integrity": "sha1-0VMiVHSe02Yg/NEBCGVJWh+p0K4="
},
"tunnel-agent": {
"version": "0.6.0",
@ -2607,4 +2607,4 @@
}
}
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.4.31",
"version": "0.4.32",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",
@ -55,4 +55,4 @@
"test": "npm -s run-script jshint && mocha -t 100000",
"start": "node ./lib/autorestPlugin/pluginHost.js"
}
}
}