@@ -305,7 +305,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) { | |||
tags = operation.tags; | |||
} | |||
var operationId = this.idFromOp(path, httpMethod, operation); | |||
var operation = new Operation ( | |||
var operationObject = new Operation ( | |||
this, | |||
operationId, | |||
httpMethod, | |||
@@ -325,11 +325,11 @@ SwaggerClient.prototype.buildFromSpec = function(response) { | |||
operationGroup.label = tag; | |||
operationGroup.apis = []; | |||
this[tag].help = this.help.bind(operationGroup); | |||
this.apisArray.push(new OperationGroup(tag, operation)); | |||
this.apisArray.push(new OperationGroup(tag, operationObject)); | |||
} | |||
operationGroup[operationId] = operation.execute.bind(operation); | |||
operationGroup[operationId].help = operation.help.bind(operation); | |||
operationGroup.apis.push(operation); | |||
operationGroup[operationId] = operationObject.execute.bind(operationObject); | |||
operationGroup[operationId].help = operationObject.help.bind(operationObject); | |||
operationGroup.apis.push(operationObject); | |||
// legacy UI feature | |||
var j; | |||
@@ -340,7 +340,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) { | |||
} | |||
} | |||
if(api) { | |||
api.operationsArray.push(operation); | |||
api.operationsArray.push(operationObject); | |||
} | |||
} | |||
} | |||
@@ -405,6 +405,7 @@ var OperationGroup = function(tag, operation) { | |||
var Operation = function(parent, operationId, httpMethod, path, args, definitions) { | |||
var errors = []; | |||
this.operation = args; | |||
this.deprecated = args.deprecated; | |||
this.consumes = args.consumes; | |||
this.produces = args.produces; | |||
this.parent = parent; | |||
@@ -439,6 +440,30 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition | |||
response = responses['200']; | |||
defaultResponseCode = '200'; | |||
} | |||
else if(responses['201']) { | |||
response = responses['201']; | |||
defaultResponseCode = '201'; | |||
} | |||
else if(responses['202']) { | |||
response = responses['202']; | |||
defaultResponseCode = '202'; | |||
} | |||
else if(responses['203']) { | |||
response = responses['203']; | |||
defaultResponseCode = '203'; | |||
} | |||
else if(responses['204']) { | |||
response = responses['204']; | |||
defaultResponseCode = '204'; | |||
} | |||
else if(responses['205']) { | |||
response = responses['205']; | |||
defaultResponseCode = '205'; | |||
} | |||
else if(responses['206']) { | |||
response = responses['206']; | |||
defaultResponseCode = '206'; | |||
} | |||
else if(responses['default']) { | |||
response = responses['default']; | |||
defaultResponseCode = 'default'; | |||
@@ -1755,7 +1755,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; | |||
type = param.type || param.dataType; | |||
if (typeof type === 'undefined') { | |||
schema = param.schema; | |||
if (schema['$ref']) { | |||
if (schema && schema['$ref']) { | |||
ref = schema['$ref']; | |||
if (ref.indexOf('#/definitions/') === 0) { | |||
type = ref.substring('#/definitions/'.length); | |||
@@ -2209,7 +2209,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; | |||
type = this.model.type || this.model.dataType; | |||
if (typeof type === 'undefined') { | |||
schema = this.model.schema; | |||
if (schema['$ref']) { | |||
if (schema && schema['$ref']) { | |||
ref = schema['$ref']; | |||
if (ref.indexOf('#/definitions/') === 0) { | |||
type = ref.substring('#/definitions/'.length); | |||
@@ -305,7 +305,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) { | |||
tags = operation.tags; | |||
} | |||
var operationId = this.idFromOp(path, httpMethod, operation); | |||
var operation = new Operation ( | |||
var operationObject = new Operation ( | |||
this, | |||
operationId, | |||
httpMethod, | |||
@@ -325,11 +325,11 @@ SwaggerClient.prototype.buildFromSpec = function(response) { | |||
operationGroup.label = tag; | |||
operationGroup.apis = []; | |||
this[tag].help = this.help.bind(operationGroup); | |||
this.apisArray.push(new OperationGroup(tag, operation)); | |||
this.apisArray.push(new OperationGroup(tag, operationObject)); | |||
} | |||
operationGroup[operationId] = operation.execute.bind(operation); | |||
operationGroup[operationId].help = operation.help.bind(operation); | |||
operationGroup.apis.push(operation); | |||
operationGroup[operationId] = operationObject.execute.bind(operationObject); | |||
operationGroup[operationId].help = operationObject.help.bind(operationObject); | |||
operationGroup.apis.push(operationObject); | |||
// legacy UI feature | |||
var j; | |||
@@ -340,7 +340,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) { | |||
} | |||
} | |||
if(api) { | |||
api.operationsArray.push(operation); | |||
api.operationsArray.push(operationObject); | |||
} | |||
} | |||
} | |||
@@ -405,6 +405,7 @@ var OperationGroup = function(tag, operation) { | |||
var Operation = function(parent, operationId, httpMethod, path, args, definitions) { | |||
var errors = []; | |||
this.operation = args; | |||
this.deprecated = args.deprecated; | |||
this.consumes = args.consumes; | |||
this.produces = args.produces; | |||
this.parent = parent; | |||
@@ -439,6 +440,30 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition | |||
response = responses['200']; | |||
defaultResponseCode = '200'; | |||
} | |||
else if(responses['201']) { | |||
response = responses['201']; | |||
defaultResponseCode = '201'; | |||
} | |||
else if(responses['202']) { | |||
response = responses['202']; | |||
defaultResponseCode = '202'; | |||
} | |||
else if(responses['203']) { | |||
response = responses['203']; | |||
defaultResponseCode = '203'; | |||
} | |||
else if(responses['204']) { | |||
response = responses['204']; | |||
defaultResponseCode = '204'; | |||
} | |||
else if(responses['205']) { | |||
response = responses['205']; | |||
defaultResponseCode = '205'; | |||
} | |||
else if(responses['206']) { | |||
response = responses['206']; | |||
defaultResponseCode = '206'; | |||
} | |||
else if(responses['default']) { | |||
response = responses['default']; | |||
defaultResponseCode = 'default'; | |||
@@ -97,7 +97,7 @@ class OperationView extends Backbone.View | |||
type = param.type || param.dataType | |||
if typeof type is 'undefined' | |||
schema = param.schema | |||
if schema['$ref'] | |||
if schema and schema['$ref'] | |||
ref = schema['$ref'] | |||
if ref.indexOf('#/definitions/') is 0 | |||
type = ref.substring('#/definitions/'.length) | |||
@@ -12,7 +12,7 @@ class ParameterView extends Backbone.View | |||
if typeof type is 'undefined' | |||
schema = @model.schema | |||
if schema['$ref'] | |||
if schema and schema['$ref'] | |||
ref = schema['$ref'] | |||
if ref.indexOf('#/definitions/') is 0 | |||
type = ref.substring('#/definitions/'.length) | |||