title: Ignoring swagger endpoints which are not in Golang router
body: <p>I am using swagger to generate documentation of REST APIs in Golang. I have multiple micro-services in my project. Some of the APIs are common to all the services so I have kept them  common. So my Golang code looks like this:</p>
  <pre><code>import othercontroller &quot;github.com/controllerv2&quot;
  func Controller() {
      ...
  
      // version V1 gpd
      router.HandleFunc(utils.BasePath+&quot;/entity&quot;, c.handleCreate).Methods(http.MethodPost)
      router.HandleFunc(utils.BasePath+&quot;/entity/{id}&quot;, c.handleDelete).Methods(http.MethodDelete)
  
      othercontroller.AttachStatRoutes(utils.BasePath, router)
      router.Serve()
  }
  </code></pre>
  <p>APIs in &quot;othercontroller&quot; looks something like this:</p>
  <pre><code>
  func AttachStatRoutes(basepath string, router Router) {
      router.HandleFunc(basepath+&quot;/stats&quot;, getStatsHandler).Methods(&quot;GET&quot;)
  }
  
  func AttachHealthRoutes(basepath string, router Router) {
      router.HandleFunc(basepath+&quot;/health&quot;, getHealthHandler).Methods(&quot;GET&quot;)
  }
  
  </code></pre>
  <p>Swagger definition for getStatsHandler API looks like this</p>
  <pre><code>// swagger:operation GET /stats  Stat
  //
  //
  // ---
  // produces:
  // - application/json
  // parameters:
  // - name: ID
  //   in: query
  //   description: stats ID
  //   required: false
  //   type: string
  // responses:
  //   '200':
  //     description: Stats response
  //     schema:
  //       &quot;$ref&quot;: &quot;#/definitions/StatsResponse&quot;
  //   '400':
  //     description: Bad Request
  //   '403':
  //     description: Forbidden, you are not authorized
  //   '500':
  //     description: Error occurred while processing the request
  
  func getStatsHandler(w http.ResponseWriter, r *http.Request) {
      // some logic here
  }
  </code></pre>
  <p>&quot;getHealthHandler&quot; API of AttachHealthRoutes() function is also in the same package and has similar swagger UI definition.</p>
  <p>Now when I generate the swagger, I am also getting swagger UI for APIs which are in AttachHealthRoutes() function but I am not attaching it to the router.</p>
  <p>So what I need is, swagger should only show me UI for APIs which are attached to routers.
  What I am assuming is, I am getting the swagger for API of AttachHealthRoutes() becasue getHealthHandler is in the same package as that of getStatHandler.</p>
  <p>Note that I can not keep them in different packages.</p>
  <p>Can anyone tell me how can I get rid of getHealthHandler API from swagger UI?</p>