updated client to enable auth #588

This commit is contained in:
Tony Tam
2014-09-20 21:21:04 -07:00
parent fedb12960b
commit 0cabc3017b
2 changed files with 20 additions and 52 deletions

View File

@@ -237,12 +237,10 @@ SwaggerClient.prototype.build = function() {
if(responseObj.swagger && responseObj.swagger === 2.0) {
self.swaggerVersion = responseObj.swagger;
self.buildFromSpec(responseObj);
self.isValid = true;
}
else {
self.isValid = false;
self.failure()
this.isValid = true;
}
else
this.isValid = false;
}
}
};
@@ -288,7 +286,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
for(httpMethod in response.paths[path]) {
var operation = response.paths[path][httpMethod];
var tags = operation.tags;
if(typeof tags === undefined)
if(typeof tags === 'undefined')
tags = [];
var operationId = this.idFromOp(path, httpMethod, operation);
var operation = new Operation (
@@ -404,8 +402,7 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
this.summary = args.summary || '';
this.responses = (args.responses||{});
this.type = null;
// this.authorizations = authorizations;
this.security = args.security;
var i;
for(i = 0; i < this.parameters.length; i++) {
@@ -436,8 +433,6 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
this.type = response.schema.type;
}
}
// else
// this.responseClassSignature = '';
if (errors.length > 0)
this.resource.api.fail(errors);
@@ -472,9 +467,8 @@ Operation.prototype.getType = function (param) {
str = 'string';
else if(type === 'array') {
isArray = true;
if(param.items) {
if(param.items)
str = this.getType(param.items);
}
}
if(param['$ref'])
str = param['$ref'];
@@ -485,7 +479,7 @@ Operation.prototype.getType = function (param) {
if(ref) {
ref = simpleRef(ref);
if(isArray)
return [ref];
return [ ref ];
else
return ref;
}
@@ -493,7 +487,7 @@ Operation.prototype.getType = function (param) {
return this.getType(schema);
}
if(isArray)
return [str];
return [ str ];
else
return str;
}
@@ -510,16 +504,6 @@ Operation.prototype.resolveModel = function (schema, definitions) {
return new ArrayModel(schema);
else
return null;
// return new PrimitiveModel(schema);
// else
// var ref = schema.items['$ref'];
// if(ref.indexOf('#/definitions/') === 0)
// ref = ref.substring('#/definitions/'.length);
// return new Model('name', models[ref]);
// }
// else
// return new Model('name', schema);
}
Operation.prototype.help = function() {
@@ -538,7 +522,6 @@ Operation.prototype.getSignature = function(type, models) {
type = type[0];
}
// listType = this.isListType(type);
if(type === 'string')
isPrimitive = true
else
@@ -664,7 +647,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
var obj = {
url: url,
method: this.method,
method: args.method,
useJQuery: this.useJQuery,
headers: headers,
on: {
@@ -676,6 +659,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
}
}
};
var status = e.authorizations.apply(obj, this.operation.security);
new SwaggerHttp().execute(obj);
}