swagger-client
Advanced tools
Comparing version 2.1.11 to 2.1.12
@@ -223,3 +223,3 @@ 'use strict'; | ||
setTimeout(function () { | ||
new Resolver().resolve(self.spec, self.buildFromSpec, self); | ||
new Resolver().resolve(self.spec, self.url, self.buildFromSpec, self); | ||
}, 10); | ||
@@ -428,2 +428,8 @@ } else { | ||
_.forEach(response.definitions, function (definitionObj, definition) { | ||
definitionObj['id'] = definition.toLowerCase(); | ||
definitionObj['name'] = definition; | ||
self.modelsArray.push(definitionObj); | ||
}); | ||
this.isBuilt = true; | ||
@@ -430,0 +436,0 @@ |
@@ -13,3 +13,5 @@ 'use strict'; | ||
*/ | ||
var JQueryHttpClient = function () {}; | ||
var JQueryHttpClient = function () { | ||
this.type = 'JQueryHttpClient'; | ||
}; | ||
@@ -19,3 +21,5 @@ /* | ||
*/ | ||
var SuperagentHttpClient = function () {}; | ||
var SuperagentHttpClient = function () { | ||
this.type = 'SuperagentHttpClient'; | ||
}; | ||
@@ -46,3 +50,3 @@ /** | ||
// OPTIONS support | ||
if(obj.method.toLowerCase() === 'OPTIONS' && typeof client === 'SuperagentHttpClient') { | ||
if(obj.method.toLowerCase() === 'options' && client.type === 'SuperagentHttpClient') { | ||
log('forcing jQuery as OPTIONS are not supported by SuperAgent'); | ||
@@ -78,3 +82,2 @@ obj.useJQuery = true; | ||
if (_.isObject(obj) && _.isObject(obj.body)) { | ||
@@ -92,3 +95,10 @@ // special processing for file uploads via jquery | ||
client.execute(requestInterceptor(obj)); | ||
obj = requestInterceptor(obj) || obj; | ||
if (obj.beforeSend) { | ||
obj.beforeSend(function(_obj) { | ||
client.execute(_obj || obj); | ||
}); | ||
} else { | ||
client.execute(obj); | ||
} | ||
@@ -117,6 +127,10 @@ return (obj.deferred) ? obj.deferred.promise : obj; | ||
JQueryHttpClient.prototype.execute = function (obj) { | ||
var jq = this.jQuery || window.jQuery; | ||
var jq = this.jQuery || (typeof window !== 'undefined' && window.jQuery); | ||
var cb = obj.on; | ||
var request = obj; | ||
if(typeof jq === 'undefined' || jq === false) { | ||
throw new Error('Unsupported configuration! JQuery is required but not available'); | ||
} | ||
obj.type = obj.method; | ||
@@ -123,0 +137,0 @@ obj.cache = false; |
@@ -14,3 +14,5 @@ 'use strict'; | ||
*/ | ||
var Resolver = module.exports = function () {}; | ||
var Resolver = module.exports = function () { | ||
this.failedUrls = []; | ||
}; | ||
@@ -268,3 +270,4 @@ Resolver.prototype.processAllOf = function(root, name, definition, resolutionTable, unresolvedRefs, spec) { | ||
(function(item, spec, self) { | ||
if(item.root === null || item.root === root) { | ||
// NOTE: this used to be item.root === null, but I (@ponelat) have added a guard against .split, which means item.root can be '' | ||
if(!item.root || item.root === root) { | ||
// local resolve | ||
@@ -278,3 +281,3 @@ self.resolveItem(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, item); | ||
} | ||
else { | ||
else if(self.failedUrls.indexOf(item.root) === -1) { | ||
var obj = { | ||
@@ -290,2 +293,4 @@ useJQuery: false, // TODO | ||
processedCalls += 1; | ||
console.log('failed url: ' + obj.url); | ||
self.failedUrls.push(obj.url); | ||
unresolvedRefs[item.key] = { | ||
@@ -318,2 +323,12 @@ root: item.root, | ||
} | ||
else { | ||
processedCalls += 1; | ||
unresolvedRefs[item.key] = { | ||
root: item.root, | ||
location: item.location | ||
}; | ||
if (processedCalls === expectedCalls) { | ||
self.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); | ||
} | ||
} | ||
}(toResolve[ii], spec, this)); | ||
@@ -522,2 +537,6 @@ } | ||
var rootTrimmed = false; | ||
root = root || '' // Guard against .split. @fehguy, you'll need to check if this logic fits | ||
// More imporantly is how do we gracefully handle relative urls, when provided just a 'spec', not a 'url' ? | ||
if (ref) { | ||
@@ -647,2 +666,6 @@ if(ref.indexOf('../') === 0) { | ||
var name = this.uniqueName('inline_model'); | ||
if (property.title) { | ||
name = this.uniqueName(property.title); | ||
} | ||
delete property.title; | ||
this.spec.definitions[name] = _.cloneDeep(property); | ||
@@ -745,6 +768,3 @@ property['$ref'] = '#/definitions/' + name; | ||
} | ||
if(_.isObject(item)) { | ||
this.resolveAllOf(spec, item, depth + 1); | ||
} | ||
} | ||
}; |
@@ -477,3 +477,3 @@ 'use strict'; | ||
var requiredClass = propertyIsRequired ? 'required' : ''; | ||
var html = '<div' + (property.readOnly ? ' class="readOnly"' : '') + '><span class="propName ' + requiredClass + '">' + name + '</span> ('; | ||
var html = '<span class="propName ' + requiredClass + '">' + name + '</span> ('; | ||
var model; | ||
@@ -520,8 +520,8 @@ var propDescription; | ||
return primitiveToOptionsHTML(cProperty, html); | ||
return '<div' + (property.readOnly ? ' class="readOnly"' : '') + '>' + primitiveToOptionsHTML(cProperty, html); | ||
}).join(',</div>'); | ||
} | ||
if (contents) { | ||
html += contents + '</div>'; | ||
if (contents) { | ||
html += contents + '</div>'; | ||
} | ||
} | ||
@@ -528,0 +528,0 @@ } else { |
@@ -134,3 +134,3 @@ 'use strict'; | ||
var existingModel = obj[name]; | ||
var _enum = []; | ||
var _required = []; | ||
var schema = { properties: {}}; | ||
@@ -149,14 +149,14 @@ var propertyName; | ||
if(typeof existingProperty.required === 'boolean' && existingProperty.required === true) { | ||
_enum.push(propertyName); | ||
_required.push(propertyName); | ||
} | ||
if(typeof existingProperty.required === 'string' && existingProperty.required === 'true') { | ||
_enum.push(propertyName); | ||
_required.push(propertyName); | ||
} | ||
schema.properties[propertyName] = property; | ||
} | ||
if(_enum.length > 0) { | ||
schema['enum'] = _enum; | ||
if(_required.length > 0) { | ||
schema.required = _required; | ||
} else { | ||
schema.required = existingModel.required; | ||
} | ||
schema.required = existingModel.required; | ||
swagger.definitions[name] = schema; | ||
@@ -163,0 +163,0 @@ } |
@@ -24,4 +24,4 @@ 'use strict'; | ||
// Note! This function will be removed in 2.2.x! | ||
Model.prototype.createJSONSample = Model.prototype.getSampleValue = function (modelsToIgnore) { | ||
log('Methods createJSONSample and getSampleValue are deprecated', 'color: red;'); | ||
modelsToIgnore = modelsToIgnore || {}; | ||
@@ -46,4 +46,3 @@ | ||
Model.prototype.getMockSignature = function () { | ||
log('Method getMockSignature is deprecated', 'color: red;'); | ||
return SchemaMarkup.schemaToHTML(this.name, this.definition, this.models, this.modelPropertyMacro); | ||
}; |
@@ -11,3 +11,3 @@ { | ||
"description": "swagger-client is a javascript client for use with swaggering APIs.", | ||
"version": "2.1.11", | ||
"version": "2.1.12", | ||
"homepage": "http://swagger.io", | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -273,1 +273,4 @@ # Swagger JS library | ||
limitations under the License. | ||
--- | ||
<img src="http://swagger.io/wp-content/uploads/2016/02/logo.jpg"/> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276
1940578
23898
8