title: RoR - Change Swagger API path to api.my-domain.com
body: <p>I have <a href="https://github.com/d4be4st/swagger-ui_rails" rel="nofollow">swagger-ui_rails</a> integrated in my existing Rails app. It successfully browses api-docs at <a href="http://my-domain.com/api-docs" rel="nofollow">http://my-domain.com/api-docs</a> and my API is hosted on <a href="http://my-domain.com/api/v1/my-model.json" rel="nofollow">http://my-domain.com/api/v1/my-model.json</a>.</p>
  
  <p><strong>How can I change my API path to <a href="http://api.my-domain.com/v1/my-model.json" rel="nofollow">http://api.my-domain.com/v1/my-model.json</a> ?</strong></p>
  
  <p><strong>Do I need to create a sub domain api.my-domain.com as well ?</strong></p>
  
  <p>My <code>swagger_docs.rb</code> looks like this:</p>
  
  <pre><code>class Swagger::Docs::Config
    def self.transform_path(path)
      "api-docs/#{path}"
    end
  end
  
  Swagger::Docs::Config.register_apis({
    "1.0" =&gt; {
      :api_extension_type =&gt; :json,
      :api_file_path =&gt; "public/api-docs",
      :base_path =&gt; "http://www.my-domain.com/",
      :clean_directory =&gt; true
    }
  })
  </code></pre>
  
  <p>After running <code>rake swagger:docs</code>, my <code>api-docs.json</code> looks like this:</p>
  
  <pre><code>{
    "apiVersion": "1.0",
    "swaggerVersion": "1.2",
    "basePath": "http://www.my-domain.com/",
    "apis": [
      {
        "path": "api-docs/api/v1/my-model.{format}",
        "description": "My Models"
      }
    ]
  }
  </code></pre>
  
  <p>When I browse <a href="http://www.my-domain.com/api/v1/my-models" rel="nofollow">http://www.my-domain.com/api/v1/my-models</a>, it renders data correctly, looks like following:</p>
  
  <pre><code>{
    "metadata": {
      "www_path_prefix": "http://www.my-domain.com/",
      "api_path_prefix": "http://www.my-domain.com/api",
      "version": 1
    },
    "data": {
      "paging": {
        "next_page_url": "http://www.my-domain.com/api/v1/my-models?page=2",
        "total_items": 2438,
        "number_of_pages": 49,
        "items_per_page": 50,
        "current_page": 1
      },
      ....
  </code></pre>
  
  <p><strong>Note</strong>: I am not using <code>grape-swagger</code>. </p>