title: Swagger dynamic controller routing
body: <p>I'm using swagger with node and I have a need to dynamically set the path to controllers at node start. For instance, the path will either be <code>/api/controllers/foo/</code> or <code>/api/controllers/bar/</code>.</p>
  
  <p>The <a href="https://github.com/apigee-127/swagger-tools/blob/master/middleware/swagger-router.js" rel="nofollow">swagger-node documentation</a> describes the swagger configuration object. I can define the directories to search in for controllers or the router to use to resolve controllers, but overriding the existing/default <a href="https://github.com/swagger-api/swagger-node/blob/master/docs/configuration.md" rel="nofollow">swagger-tools router</a> seems like overkill, and setting the controllers directories doesn't work because I need the directory to be either <code>foo</code> or <code>bar</code>, not both.</p>
  
  <pre><code># swagger configuration file
  
  # values in the swagger hash are system configuration for swagger-node
  swagger:
  
  fittingsDirs: [ api/fittings, node_modules ]
  defaultPipe: null
  swaggerControllerPipe: swagger_controllers  # defines the standard processing pipe for controllers
  
  # values defined in the bagpipes key are the bagpipes pipes and fittings definitions
  # (see https://github.com/apigee-127/bagpipes)
  bagpipes:
  
    _router:
      name: swagger_router
      mockMode: false
      mockControllersDirs: [ api/mocks ]
      controllersDirs: [ api/controllers ]
  
    _swagger_validate:
      name: swagger_validator
      validateResponse: true
  
    # pipe for all swagger-node controllers
    swagger_controllers:
      - onError: json_error_handler
      - cors
      - swagger_security
      - _swagger_validate
      - express_compatibility
      - _router
  
    # pipe to serve swagger (endpoint is in swagger.yaml)
    swagger_raw:
      name: swagger_raw
  
  # any other values in this file are just loaded into the config for application access...
  </code></pre>
  
  <p>I haven't been able to find any clear concise way to do this. Seems like I'm missing something. Does anyone have experience dynamically setting the controller directory dynamically? What's the best approach here?</p>