How do you add an API key in Swagger
<p>I have tried several methods to add a basic API key authorization to Swagger (express swagger). Below is the relevant info from my manifest.</p>

<pre><code>{
  ...
  "main": "app.js",
  "dependencies": {
    "express": "^4.12.3",
    "swagger-express-mw": "^0.1.0"
  },
  ...
}
</code></pre>

<p>I believe I have registered the security definitions in the YAML configuration.</p>

<pre><code>swagger: "2.0"
info:
  ...

# Set up security for the API
securityDefinitions:
  defaultApiKey:
    type: apiKey
    in: header
    name: defaultApiKey

security:
    - defaultApiKey: []
</code></pre>

<p>To finish this configuration I thought I would only need to register the middleware in the SwaggerExpress.create() function. Below is my entire app.js as it currently stands.</p>

<pre><code>'use strict';

var SwaggerExpress = require('swagger-express-mw');
var app = require('express')();
module.exports = app; // for testing

var config = {
  appRoot: __dirname // required config
};

SwaggerExpress.create(config, function(err, swaggerExpress) {
  if (err) { throw err; }

  // Serve the Swagger documents and SwaggerUi
  app.use(swaggerExpress.runner.swaggerTools.swaggerUi());

  // Install security
  app.use(swaggerExpress.swaggerSecurity({
    defaultApiKey: function(req, def, scopes, callback) {
      console.log("hit");
    }
  }));

  // install middleware
  swaggerExpress.register(app);

  var port = process.env.PORT || 10010;
  app.listen(port);
});
</code></pre>

<p>When I attempt to use this I see the following:</p>

<pre><code>Error initializing middleware
TypeError: swaggerExpress.swaggerSecurity is not a function
</code></pre>

<p>I have tried configuring this a few different ways with no success. Did I properly define the API key in YAML and if so what should I do to register the API key handler in my app.js file?</p>