added check for schema
This commit is contained in:
37
dist/lib/swagger-client.js
vendored
37
dist/lib/swagger-client.js
vendored
@@ -305,7 +305,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
|||||||
tags = operation.tags;
|
tags = operation.tags;
|
||||||
}
|
}
|
||||||
var operationId = this.idFromOp(path, httpMethod, operation);
|
var operationId = this.idFromOp(path, httpMethod, operation);
|
||||||
var operation = new Operation (
|
var operationObject = new Operation (
|
||||||
this,
|
this,
|
||||||
operationId,
|
operationId,
|
||||||
httpMethod,
|
httpMethod,
|
||||||
@@ -325,11 +325,11 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
|||||||
operationGroup.label = tag;
|
operationGroup.label = tag;
|
||||||
operationGroup.apis = [];
|
operationGroup.apis = [];
|
||||||
this[tag].help = this.help.bind(operationGroup);
|
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] = operationObject.execute.bind(operationObject);
|
||||||
operationGroup[operationId].help = operation.help.bind(operation);
|
operationGroup[operationId].help = operationObject.help.bind(operationObject);
|
||||||
operationGroup.apis.push(operation);
|
operationGroup.apis.push(operationObject);
|
||||||
|
|
||||||
// legacy UI feature
|
// legacy UI feature
|
||||||
var j;
|
var j;
|
||||||
@@ -340,7 +340,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(api) {
|
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 Operation = function(parent, operationId, httpMethod, path, args, definitions) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
this.operation = args;
|
this.operation = args;
|
||||||
|
this.deprecated = args.deprecated;
|
||||||
this.consumes = args.consumes;
|
this.consumes = args.consumes;
|
||||||
this.produces = args.produces;
|
this.produces = args.produces;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@@ -439,6 +440,30 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
|
|||||||
response = responses['200'];
|
response = responses['200'];
|
||||||
defaultResponseCode = '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']) {
|
else if(responses['default']) {
|
||||||
response = responses['default'];
|
response = responses['default'];
|
||||||
defaultResponseCode = 'default';
|
defaultResponseCode = 'default';
|
||||||
|
|||||||
4
dist/swagger-ui.js
vendored
4
dist/swagger-ui.js
vendored
@@ -1755,7 +1755,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
type = param.type || param.dataType;
|
type = param.type || param.dataType;
|
||||||
if (typeof type === 'undefined') {
|
if (typeof type === 'undefined') {
|
||||||
schema = param.schema;
|
schema = param.schema;
|
||||||
if (schema['$ref']) {
|
if (schema && schema['$ref']) {
|
||||||
ref = schema['$ref'];
|
ref = schema['$ref'];
|
||||||
if (ref.indexOf('#/definitions/') === 0) {
|
if (ref.indexOf('#/definitions/') === 0) {
|
||||||
type = ref.substring('#/definitions/'.length);
|
type = ref.substring('#/definitions/'.length);
|
||||||
@@ -2209,7 +2209,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
type = this.model.type || this.model.dataType;
|
type = this.model.type || this.model.dataType;
|
||||||
if (typeof type === 'undefined') {
|
if (typeof type === 'undefined') {
|
||||||
schema = this.model.schema;
|
schema = this.model.schema;
|
||||||
if (schema['$ref']) {
|
if (schema && schema['$ref']) {
|
||||||
ref = schema['$ref'];
|
ref = schema['$ref'];
|
||||||
if (ref.indexOf('#/definitions/') === 0) {
|
if (ref.indexOf('#/definitions/') === 0) {
|
||||||
type = ref.substring('#/definitions/'.length);
|
type = ref.substring('#/definitions/'.length);
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -305,7 +305,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
|||||||
tags = operation.tags;
|
tags = operation.tags;
|
||||||
}
|
}
|
||||||
var operationId = this.idFromOp(path, httpMethod, operation);
|
var operationId = this.idFromOp(path, httpMethod, operation);
|
||||||
var operation = new Operation (
|
var operationObject = new Operation (
|
||||||
this,
|
this,
|
||||||
operationId,
|
operationId,
|
||||||
httpMethod,
|
httpMethod,
|
||||||
@@ -325,11 +325,11 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
|||||||
operationGroup.label = tag;
|
operationGroup.label = tag;
|
||||||
operationGroup.apis = [];
|
operationGroup.apis = [];
|
||||||
this[tag].help = this.help.bind(operationGroup);
|
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] = operationObject.execute.bind(operationObject);
|
||||||
operationGroup[operationId].help = operation.help.bind(operation);
|
operationGroup[operationId].help = operationObject.help.bind(operationObject);
|
||||||
operationGroup.apis.push(operation);
|
operationGroup.apis.push(operationObject);
|
||||||
|
|
||||||
// legacy UI feature
|
// legacy UI feature
|
||||||
var j;
|
var j;
|
||||||
@@ -340,7 +340,7 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(api) {
|
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 Operation = function(parent, operationId, httpMethod, path, args, definitions) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
this.operation = args;
|
this.operation = args;
|
||||||
|
this.deprecated = args.deprecated;
|
||||||
this.consumes = args.consumes;
|
this.consumes = args.consumes;
|
||||||
this.produces = args.produces;
|
this.produces = args.produces;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@@ -439,6 +440,30 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
|
|||||||
response = responses['200'];
|
response = responses['200'];
|
||||||
defaultResponseCode = '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']) {
|
else if(responses['default']) {
|
||||||
response = responses['default'];
|
response = responses['default'];
|
||||||
defaultResponseCode = 'default';
|
defaultResponseCode = 'default';
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class OperationView extends Backbone.View
|
|||||||
type = param.type || param.dataType
|
type = param.type || param.dataType
|
||||||
if typeof type is 'undefined'
|
if typeof type is 'undefined'
|
||||||
schema = param.schema
|
schema = param.schema
|
||||||
if schema['$ref']
|
if schema and schema['$ref']
|
||||||
ref = schema['$ref']
|
ref = schema['$ref']
|
||||||
if ref.indexOf('#/definitions/') is 0
|
if ref.indexOf('#/definitions/') is 0
|
||||||
type = ref.substring('#/definitions/'.length)
|
type = ref.substring('#/definitions/'.length)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ParameterView extends Backbone.View
|
|||||||
|
|
||||||
if typeof type is 'undefined'
|
if typeof type is 'undefined'
|
||||||
schema = @model.schema
|
schema = @model.schema
|
||||||
if schema['$ref']
|
if schema and schema['$ref']
|
||||||
ref = schema['$ref']
|
ref = schema['$ref']
|
||||||
if ref.indexOf('#/definitions/') is 0
|
if ref.indexOf('#/definitions/') is 0
|
||||||
type = ref.substring('#/definitions/'.length)
|
type = ref.substring('#/definitions/'.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user