miketrionfo/Swagger.Net — pull request #13 by gregmac (2012-11-01 20:19:06+00:00)
Title: Conflicts in nicknames

SwaggerUI depends on unique nicknames for each operation (with an API), otherwise it won't allow expanding the operation.

This is most easily demonstrated/described using the default WebAPI project:

* Create a new WebAPI project
* Add Swagger UI via nuget
* Run the project, and navigate to the swagger documentation
* Among the default methods, are `GET /values` and `GET /values/{id}`
* Click on either of the two operations, and in both cases only the first one will expand.

The problem is that from the code:
```
// GET api/values
public IEnumerable Get()
{
return new string[] { "value1", "value2" };
}

// GET api/values/5
public string Get(int id)
{
return "value";
}
````
Swagger.Net generates the nickname based on the method name, so both are simply 'Get'.

The attached code changes the nickname to be based on ApiDesrption.ID, which is unique across the server (http://msdn.microsoft.com/en-us/library/system.web.http.description.apidescription.id(v=vs.108).aspx), and formats it to be HTML-anchor-friendly.

As a result, the nickname for the two operations above become `GETapi_Values` and `GETapi_Values__id_` respectively, and the UI works as expected.