fix for required fields showing optional
This commit is contained in:
42
dist/lib/swagger.js
vendored
42
dist/lib/swagger.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript 1.4.0
|
// Generated by CoffeeScript 1.4.0
|
||||||
(function() {
|
(function() {
|
||||||
var ApiKeyAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
@@ -94,6 +94,7 @@
|
|||||||
this.apis = {};
|
this.apis = {};
|
||||||
this.apisArray = [];
|
this.apisArray = [];
|
||||||
this.produces = response.produces;
|
this.produces = response.produces;
|
||||||
|
this.authSchemes = response.authorizations;
|
||||||
if (response.info != null) {
|
if (response.info != null) {
|
||||||
this.info = response.info;
|
this.info = response.info;
|
||||||
}
|
}
|
||||||
@@ -445,18 +446,19 @@
|
|||||||
SwaggerModel = (function() {
|
SwaggerModel = (function() {
|
||||||
|
|
||||||
function SwaggerModel(modelName, obj) {
|
function SwaggerModel(modelName, obj) {
|
||||||
var propertyName, value;
|
var prop, propertyName, value;
|
||||||
this.name = obj.id != null ? obj.id : modelName;
|
this.name = obj.id != null ? obj.id : modelName;
|
||||||
this.properties = [];
|
this.properties = [];
|
||||||
for (propertyName in obj.properties) {
|
for (propertyName in obj.properties) {
|
||||||
if (obj["enum"] != null) {
|
if (obj.required != null) {
|
||||||
for (value in obj["enum"]) {
|
for (value in obj.required) {
|
||||||
if (propertyName === value) {
|
if (propertyName === obj.required[value]) {
|
||||||
obj.properties[propertyName].required = true;
|
obj.properties[propertyName].required = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
||||||
|
this.properties.push(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +510,6 @@
|
|||||||
|
|
||||||
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
||||||
var prop, result, _i, _len, _ref;
|
var prop, result, _i, _len, _ref;
|
||||||
console.log("creating json sample for " + this);
|
|
||||||
result = {};
|
result = {};
|
||||||
modelsToIgnore = modelsToIgnore || [];
|
modelsToIgnore = modelsToIgnore || [];
|
||||||
modelsToIgnore.push(this.name);
|
modelsToIgnore.push(this.name);
|
||||||
@@ -530,11 +531,9 @@
|
|||||||
function SwaggerModelProperty(name, obj) {
|
function SwaggerModelProperty(name, obj) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.dataType = obj.type || obj.dataType || obj["$ref"];
|
this.dataType = obj.type || obj.dataType || obj["$ref"];
|
||||||
console.log(this.name + " has data type " + this.dataType);
|
|
||||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||||
this.descr = obj.description;
|
this.descr = obj.description;
|
||||||
this.required = obj.required;
|
this.required = obj.required;
|
||||||
console.log(this);
|
|
||||||
if (obj.items != null) {
|
if (obj.items != null) {
|
||||||
if (obj.items.type != null) {
|
if (obj.items.type != null) {
|
||||||
this.refDataType = obj.items.type;
|
this.refDataType = obj.items.type;
|
||||||
@@ -630,7 +629,6 @@
|
|||||||
this.method = this.method.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
this.isGetMethod = this.method === "get";
|
this.isGetMethod = this.method === "get";
|
||||||
this.resourceName = this.resource.name;
|
this.resourceName = this.resource.name;
|
||||||
console.log("model type: " + type);
|
|
||||||
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||||
this.type = void 0;
|
this.type = void 0;
|
||||||
}
|
}
|
||||||
@@ -1211,6 +1209,28 @@
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
PasswordAuthorization = (function() {
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.name = null;
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.username = null;
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.password = null;
|
||||||
|
|
||||||
|
function PasswordAuthorization(name, username, password) {
|
||||||
|
this.name = name;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.apply = function(obj) {
|
||||||
|
return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password);
|
||||||
|
};
|
||||||
|
|
||||||
|
return PasswordAuthorization;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
this.SwaggerApi = SwaggerApi;
|
this.SwaggerApi = SwaggerApi;
|
||||||
|
|
||||||
this.SwaggerResource = SwaggerResource;
|
this.SwaggerResource = SwaggerResource;
|
||||||
@@ -1223,6 +1243,8 @@
|
|||||||
|
|
||||||
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||||
|
|
||||||
|
this.PasswordAuthorization = PasswordAuthorization;
|
||||||
|
|
||||||
this.authorizations = new SwaggerAuthorizations();
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript 1.4.0
|
// Generated by CoffeeScript 1.4.0
|
||||||
(function() {
|
(function() {
|
||||||
var ApiKeyAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
@@ -94,6 +94,7 @@
|
|||||||
this.apis = {};
|
this.apis = {};
|
||||||
this.apisArray = [];
|
this.apisArray = [];
|
||||||
this.produces = response.produces;
|
this.produces = response.produces;
|
||||||
|
this.authSchemes = response.authorizations;
|
||||||
if (response.info != null) {
|
if (response.info != null) {
|
||||||
this.info = response.info;
|
this.info = response.info;
|
||||||
}
|
}
|
||||||
@@ -445,18 +446,19 @@
|
|||||||
SwaggerModel = (function() {
|
SwaggerModel = (function() {
|
||||||
|
|
||||||
function SwaggerModel(modelName, obj) {
|
function SwaggerModel(modelName, obj) {
|
||||||
var propertyName, value;
|
var prop, propertyName, value;
|
||||||
this.name = obj.id != null ? obj.id : modelName;
|
this.name = obj.id != null ? obj.id : modelName;
|
||||||
this.properties = [];
|
this.properties = [];
|
||||||
for (propertyName in obj.properties) {
|
for (propertyName in obj.properties) {
|
||||||
if (obj["enum"] != null) {
|
if (obj.required != null) {
|
||||||
for (value in obj["enum"]) {
|
for (value in obj.required) {
|
||||||
if (propertyName === value) {
|
if (propertyName === obj.required[value]) {
|
||||||
obj.properties[propertyName].required = true;
|
obj.properties[propertyName].required = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
||||||
|
this.properties.push(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +510,6 @@
|
|||||||
|
|
||||||
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
||||||
var prop, result, _i, _len, _ref;
|
var prop, result, _i, _len, _ref;
|
||||||
console.log("creating json sample for " + this);
|
|
||||||
result = {};
|
result = {};
|
||||||
modelsToIgnore = modelsToIgnore || [];
|
modelsToIgnore = modelsToIgnore || [];
|
||||||
modelsToIgnore.push(this.name);
|
modelsToIgnore.push(this.name);
|
||||||
@@ -530,11 +531,9 @@
|
|||||||
function SwaggerModelProperty(name, obj) {
|
function SwaggerModelProperty(name, obj) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.dataType = obj.type || obj.dataType || obj["$ref"];
|
this.dataType = obj.type || obj.dataType || obj["$ref"];
|
||||||
console.log(this.name + " has data type " + this.dataType);
|
|
||||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||||
this.descr = obj.description;
|
this.descr = obj.description;
|
||||||
this.required = obj.required;
|
this.required = obj.required;
|
||||||
console.log(this);
|
|
||||||
if (obj.items != null) {
|
if (obj.items != null) {
|
||||||
if (obj.items.type != null) {
|
if (obj.items.type != null) {
|
||||||
this.refDataType = obj.items.type;
|
this.refDataType = obj.items.type;
|
||||||
@@ -630,7 +629,6 @@
|
|||||||
this.method = this.method.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
this.isGetMethod = this.method === "get";
|
this.isGetMethod = this.method === "get";
|
||||||
this.resourceName = this.resource.name;
|
this.resourceName = this.resource.name;
|
||||||
console.log("model type: " + type);
|
|
||||||
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||||
this.type = void 0;
|
this.type = void 0;
|
||||||
}
|
}
|
||||||
@@ -1211,6 +1209,28 @@
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
PasswordAuthorization = (function() {
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.name = null;
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.username = null;
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.password = null;
|
||||||
|
|
||||||
|
function PasswordAuthorization(name, username, password) {
|
||||||
|
this.name = name;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
PasswordAuthorization.prototype.apply = function(obj) {
|
||||||
|
return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password);
|
||||||
|
};
|
||||||
|
|
||||||
|
return PasswordAuthorization;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
this.SwaggerApi = SwaggerApi;
|
this.SwaggerApi = SwaggerApi;
|
||||||
|
|
||||||
this.SwaggerResource = SwaggerResource;
|
this.SwaggerResource = SwaggerResource;
|
||||||
@@ -1223,6 +1243,8 @@
|
|||||||
|
|
||||||
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||||
|
|
||||||
|
this.PasswordAuthorization = PasswordAuthorization;
|
||||||
|
|
||||||
this.authorizations = new SwaggerAuthorizations();
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user