registerApi - the factory for middleware that registers api in response object

@param  {ModelAPIRouter|ModelAPIExpress} apiObject the ModelAPIRouter or ModelAPIRouter
@return {Function}           description
171190
function registerApi(isApp, apiObject) {

  if (isApp) {
    return function (req, res, next) {
      res.__api = apiObject;
      return next();
    };
  };
  
  return function (req, res, next) {
    res.__modelAPI = apiObject;
    return next();
  };
}
495862
function(apiId) {
        return APIG.getStages({
            restApiId: apiId
        }).promise().then(function(data) {
            return data.item;
        });
    }
880385
private function registerApiMiddleware()
    {
        /** @var  \Illuminate\Contracts\Config\Repository  $config */
        $config = $this->app['config'];

        foreach ($config->get('api-helper.middleware', []) as $name => $class) {
            $this->aliasMiddleware($name, $class);
        };
    }
1249445
def _register_options(self, api_interface):
        # type: (ApiInterfaceBase) -> None
        
        op_paths = api_interface.op_paths(collate_methods=True)
        for path, operations in op_paths.items():
            if api.Method.OPTIONS not in operations:
                self._options_operation(api_interface, path, operations.keys())
265454
function setApi() {
            self.api = {};
            if(process && process.env && process.env.APPVEYOR_API_URL) {
                var fullUrl = process.env.APPVEYOR_API_URL;

                var urlParts = fullUrl.split("/")[2].split(":");
                self.api = {
                    host: urlParts[0],
                    port: urlParts[1],
                    endpoint: "/api/tests/batch"
                };
            }
            else {
                throw Error("Not running in AppVeyor environment");
            }
        }
999037
def _get_api_id(self, event_properties):
        
        api_id = event_properties.get("RestApiId")
        if isinstance(api_id, dict) and "Ref" in api_id:
            api_id = api_id["Ref"]
        return api_id
341641
async function api(endpoint, token) {
	token = token ? `&access_token=${token}` : '';
	const response = await fetch(`https://api.github.com/repos/${endpoint}${token}`);
	return response.json();
}
450819
def registerAPI(self, name, handler, container = None, discoverinfo = None, criteria = None):
        
        self.handler.registerHandler(*self._createHandler(name, handler, container, criteria))
        if discoverinfo is None:
            self.discoverinfo[name] = {'description': cleandoc(handler.__doc__)}
        else:
            self.discoverinfo[name] = discoverinfo
1037743
function callApi(method, parameters, callback) {

    if (typeof parameters === 'undefined') {
        throw new Error('undefined is not a valid parameters object.');
    }

    if( typeof parameters !== 'object' ){
        throw new Error('valid parameters object required.');
    }

    var opts = this.options;

    var noCallback = !callback || typeof callback !== 'function';
    let noApiKey = typeof opts.API_KEY !== 'string' || opts.API_KEY.length === 0 || typeof opts.API_SECRET !== 'string' || opts.API_SECRET.length === 0;
    if( noApiKey ){
        if( noCallback ){
            throw new Error('API key and API secret required.');
        }
        return callback(new Error("API key and API secret required."));
    }

    opts.method = method;

    //
    // final API url with hashes
    //
    let url = makeApiUrl(opts, parameters);

    let reqOptions = {
        uri: url,
        json: true,
        timeout: process.env.CF_TIMEOUT || opts.DEFAULT_TIMEOUT
    };


    //
    // callback not exists, just return the request modules Request class instance for event
    //
    if( noCallback ){
        return new Request(reqOptions);
    }

    //
    // callback exists, return Request for streaming and handle callback for error handling and custom formatted data
    //
    return callRequest(reqOptions, handleCallback.bind(null,callback) );
}
13874
function createApi () {
  api = {
    eth: {
      blockNumber: sinon.stub().resolves(new BigNumber(2)),
      gasPrice: sinon.stub().resolves(GASPRICE)
    },
    parity: {
      gasPriceHistogram: sinon.stub().resolves(HISTOGRAM)
    }
  };

  return api;
}
897685
function executeApi(apiName, opts, extras){

  var emitter = new Emitter()
    , apiItem
    , token = opts.access_token
    , form, method, path
    , url
    ;
  
  if(/^(https?:\/\/|\/)/.test(apiName)){
    if(apiName.indexOf('/') === 0){
      url = api.HOST + apiName;
    }else{
      url = apiName;
    }
    extras = extras || {};
    method = extras.method;
    
  }else{
    apiItem = getApiItem(apiName);
    if(!apiItem){
      process.nextTick(function(){
        emitter.emit('error', 'no or not support api: ' + apiName);
      });
      return emitter;
    }
    
    path = apiItem.path;
    method = apiItem.method;
    
    url = api.HOST + api.PREPATH + path + '.json';
  }
  
  if(method == 'post'){
    form = opts;
    opts = {};
  }
  
  delete opts.access_token;
  
  request({
      url: url + '?access_token=' + token
    , method: method
    , qs: opts
    , form: form
  }, function(err, res, reply){
    if(err){
      emitter.emit('error', err);
    }else{
      try{
        reply = JSON.parse(reply);
        emitter.emit('success', reply);
      }catch(e){
        emitter.emit('error', reply);
      }
    }
  });
  
  return emitter;
}
714955
function Api(config) {
  // config
  this._config = config || {};
  this._config.transforms = _.merge(this._config.transforms || {},{
    defaults: {
      serialize: JSON.stringify,
      deserialize: JSON.parse
    }
  });

  this._config.headers = this._config.headers || {};

  // stack of [('one' | 'all'), <noun>, <id?>]
  // ex [['all', 'experiments'] or ['one', 'projects', 4001]]
  this._stack = [];

  /**
   * Array of filters to apply to URL
   * ex: /api/v1/projects/4001/experiments?filter=status:Started&filter=project_id:55
   * @var Array.<{field: string, value: string}>
   */
  this._filter = [];
}
1254795
function ( pm, url, type, data, success ) {

	    	// Almost all calls to the API need to be done including a per-user API token.
	    	// This token is passed into the constructor below and gets automatically 
	    	// added to each call here if it is not already present.

	    	if ( !pm.api_key && !url.match(/\/user\/login$/) ) {
	    		throw( "PieceMakerApi: need an API_KEY, please login first to obtain one" );
	    	}

	    	var ts = (new Date()).getTime();
	    	var callUrl = url + '.json';

	        ajaxImpl({
	                url: callUrl,
	                type: type,
	                dataType: 'json',
	                data: data || {},
					// before: function ( xhr ) {
					// 	if ( !url.match(/\/user\/login$/) ) {
					// 		xhr.setRequestHeader( 'X-Access-Key', api.api_key );
					// 	}
					// },
					context: pm,
	                success: function () {
	                	if ( arguments && arguments[0] && 
	                		 typeof arguments[0] === 'object' && 
	                		 !(arguments[0] instanceof Array) && 
	                		 !('queryTime' in arguments[0]) ) {
	                		arguments[0]['queryTime'] = ((new Date()).getTime()) - ts;
	                	}
	                	success.apply( pm, arguments );
	                },
	                error: function (err) {
	                    xhrError( pm, callUrl, type, err );
	                },
	                /* , xhrFields: { withCredentials: true } */
					/* , headers: { 'Cookie' : document.cookie } */
					headers: {
						'X-Access-Key': pm.api_key
					}
	            });
	    }
1156892
def register(**kwargs):
    
    def decorator(func):
        _CALL_REGISTRY[kwargs.get(API_SYM, func.__name__)] = func
        return func

    return decorator
163040
function(apiId) {
        return new Promise(function(resolve, reject) {
            APIG.deleteRestApi({
                restApiId: apiId
            }, function(err) {
                if (err) {
                    if (err.code === 404 || err.code === 'NotFoundException') {
                        // API didn't exist to begin with
                        return resolve(apiId);
                    }

                    return reject(err);
                }

                resolve(apiId);
            });
        });
    }
94127
public static SystemInputDef getResponseInputModel( OpenAPI api, ModelOptions options)
    {
    ResponseInputModeller inputModeller = new ResponseInputModeller( options);
    return inputModeller.getResponseInputModel( api);
    }
890485
function CurlApi (ids, callback, errback, waitFor) {
		var then, ctx;
		ctx = core.createContext(userCfg, undef, [].concat(ids));
		this['then'] = then = function (resolved, rejected) {
			when(ctx,
				// return the dependencies as arguments, not an array
				function (deps) {
					if (resolved) resolved.apply(undef, deps);
				},
				// just throw if the dev didn't specify an error handler
				function (ex) {
					if (rejected) rejected(ex); else throw ex;
				}
			);
			return this;
		};
		this['next'] = function (ids, cb, eb) {
			// chain api
			return new CurlApi(ids, cb, eb, ctx);
		};
		this['config'] = _config;
		if (callback || errback) then(callback, errback);
		when(waitFor, function () { core.getDeps(ctx); });
	}