Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ SwaggerClient.prototype.build = function (mock) {
if (responseObj.swagger && parseInt(responseObj.swagger) === 2) {
self.swaggerVersion = responseObj.swagger;

new Resolver().resolve(responseObj, self.url, self.buildFromSpec, self);
new Resolver(options).resolve(responseObj, self.url, self.buildFromSpec, self);

self.isValid = true;
} else {
Expand All @@ -209,7 +209,7 @@ SwaggerClient.prototype.build = function (mock) {
converter.setDocumentationLocation(self.url);
converter.convert(responseObj, self.clientAuthorizations, self.options, function(spec) {
self.swaggerObject = spec;
new Resolver().resolve(spec, self.url, self.buildFromSpec, self);
new Resolver(options).resolve(spec, self.url, self.buildFromSpec, self);
self.isValid = true;
});
}
Expand All @@ -220,7 +220,7 @@ SwaggerClient.prototype.build = function (mock) {
if (this.spec) {
self.swaggerObject = this.spec;
setTimeout(function () {
new Resolver().resolve(self.spec, self.buildFromSpec, self);
new Resolver(options).resolve(self.spec, self.buildFromSpec, self);
}, 10);
} else {
this.clientAuthorizations.apply(obj);
Expand Down
16 changes: 11 additions & 5 deletions lib/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ var _ = {
/**
* Resolves a spec's remote references
*/
var Resolver = module.exports = function () {};
var Resolver = module.exports = function (options) {
//Ensures downwards compatibility if no explicit options object is provided
var DEFAULT_OPTIONS = {
disableAllOfResolving: false
};

this.options = options || DEFAULT_OPTIONS
};

Resolver.prototype.processAllOf = function(root, name, definition, resolutionTable, unresolvedRefs, spec) {
var i, location, property;
Expand Down Expand Up @@ -405,7 +412,9 @@ Resolver.prototype.finish = function (spec, root, resolutionTable, resolvedRefs,
var existingUnresolved = this.countUnresolvedRefs(spec);

if(existingUnresolved === 0 || this.iteration > 5) {
this.resolveAllOf(spec.definitions);
if(!this.options.disableAllOfResolving) {
this.resolveAllOf(spec.definitions);
}
callback.call(this.scope, spec, unresolvedRefs);
}
else {
Expand Down Expand Up @@ -670,9 +679,6 @@ Resolver.prototype.resolveAllOf = function(spec, obj, depth) {
if(item === null) {
throw new TypeError('Swagger 2.0 does not support null types (' + obj + '). See https://github.com/swagger-api/swagger-spec/issues/229.');
}
if(typeof item === 'object') {
this.resolveAllOf(spec, item, depth + 1);
}
if(item && typeof item.allOf !== 'undefined') {
var allOf = item.allOf;
if(_.isArray(allOf)) {
Expand Down