How to use the swagger-client.SwaggerApi function in swagger-client

To help you get started, we’ve selected a few swagger-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asterisk / node-ari-client / Gruntfile.js View on Github external
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));
github asterisk / node-ari-client / lib / client.js View on Github external
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
        });
      }
    });
github codeandfury / node-hapi-swagger-models / index.js View on Github external
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];