Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
swagger.authorizations.add(
'basic-auth',
new swagger.PasswordAuthorization(
parsedUrl.hostname,
options.username,
options.password
)
);
// Connect to API using swagger and attach resources on Client instance
var resourcesUrl = util.format(
'%s//%s/ari/api-docs/resources.json',
parsedUrl.protocol,
parsedUrl.host
);
var swaggerClient = new swagger.SwaggerApi({
url: resourcesUrl,
success: swaggerLoaded,
failure: swaggerFailed
});
// Swagger success callback
function swaggerLoaded () {
if(swaggerClient.ready === true) {
grunt.log.writeln('generating operations documentation');
var apis = _.sortBy(_.keys(swaggerClient.apis));
_.each(apis, generateOperations);
grunt.log.writeln('generating events documentation');
var models = _.sortBy(_.keys(swaggerClient.apis.events.models));
request(ariUrl, function (err) {
if (err &&
['ETIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED'].indexOf(err.code) !== -1) {
err.name = 'HostIsNotReachable';
self.emit('APILoadError', err);
reject(err);
} else {
self._swagger = new swagger.SwaggerApi({
url: ariUrl,
success: swaggerLoaded,
failure: swaggerFailed
});
}
});
handler: function(request, reply) {
var swagger = new client.SwaggerApi({
url: config.api,
success: function() {
var api,
apiName,
model,
modelName,
property,
script,
scriptModel,
scriptValidation;
script = [];
if (swagger.ready === true) {
for (apiName in swagger.apis) {
api = swagger.apis[apiName];
for (modelName in api.models) {
model = api.models[modelName];