richhollis/swagger-docs — pull request #79 by tiagoamaro (2014-08-29 15:09:51+00:00)
Title: Expose API version on transform_path for easier “No Server Integrations”

Hello,

Thanks for this awesome gem. It was really easy to generate swagger JSON with this :)

This pull request aims on the following issue: it is interesting exposing the `api_version` variable on the `Swagger::Docs::Config.tranform_path` method.

# Why?

- I'm trying to generate multiple docs for more than one version of my API (v1, v2, v3, etc.)
- I'm following the 'No Server Integration' strategy
- The Swagger JSONs were stored on my public folder (`public/api-docs`)

I Tried to generate the docs, but each version overwrote `api-docs.json` generated by this gem. Example:

On the config I had:

```ruby
class Swagger::Docs::Config
def self.transform_path(path)
"api-docs/#{path}"
end
end

Swagger::Docs::Config.register_apis({
"v0" => { ... },
"v1" => { ... }
)}
```

After running the rake I got only one `api-docs.json`:

```
{
"apiVersion": "v1",
"swaggerVersion": "1.2",
"basePath": "/",
"apis": [
..
]
}
```

After that, I tried changing my `api_file_path` for each API version (v0 was `public/api-docs/v0` and v1 was `public/api-docs/v1`).

It generated successfully, but the `api-docs.json` for each version didn't reflect my public path folder.