khellang/Nancy.Swagger — pull request #46 by TimSchlechter (2014-08-26 18:38:56+00:00)
Title: Embed swagger-ui and expose a SwaggerUIModule

@khellang wrote about embedding swagger-ui in some past issues/pull-requests, and I hadn't done anything like this. So I was curious about how to do something like this, and tried some things.

I came to a working solution, which is in this PR but I don't have a clue if this is the way to go. But it might be worth sharing. I did the following:

Embedded swagger-ui in Nancy.Swagger by adding the following into the csrpoj
```xml

Resources\swagger-ui\%(RecursiveDir)%(FileName)

```

I added a SwaggerUIModule which serves the embedded resources and made the swagger-ui path configurable by SwaggerConfig.SwaggerUIPath.
I had to pull some dark, black magic to get from a path to the embedded resource name. Not very proud of it, but it seems to work.

I had to add a custom index.html for swagger-ui, since I thought it might be nice to set the path to the Swagger API docs:
```javascript
$(function () {
window.swaggerUi = new SwaggerUi({
url: "{{ResourceListingPath}}",
// ...
```

The last change this PR contains is removing the post-build event in the Demo project, since swagger-ui is embedded now.

As said above, I have absolutely no idea this is the way to go but it might be a start :grimacing: