3

I have a project that was using the ServiceStack with Swagger-UI, I have installed and setup this up with v4.0.24 and recently upgraded to v4.0.30.

The latest ServiceStack.Api.Swagger NuGet package : https://www.nuget.org/packages/ServiceStack.Api.Swagger/ Does not seem to install the /swagger-ui resource folder as the previous package did.

I tried this with a new clean servicestack asp.net solution in VS2013. Added ServiceStack.Api.Swagger from nuget, and enabled the plugin in AppHost.cs thus :

public override void Configure(Container container)
{
    this.AddPlugin(new SwaggerFeature());
}

The swagger-ui feature seems to works fine, but it appears the resources (index.html, js, css, etc.) are embedded in the dll, and it is required to edit the index.html at a minumum to configure Swagger-UI.

Am I missing something, or is this a bug in the latest NuGet package?

I have edited my swagger v4.0.24 html, css and js, am I safe to pull these from the ServiceStack Git (https://github.com/ServiceStack/ServiceStack/tree/master/src/ServiceStack.Api.Swagger) and manually add / merge them to my solution?

4

1 回答 1

8

查看ServiceStack 发行说明以了解每个版本中的更改是一个好主意。

v4.0.30中Swagger 更改的注意事项:

现在嵌入所有静态资源

Swagger 的所有静态资源都嵌入到单个ServiceStack.Api.Swagger.dll中,利用虚拟文件系统对 Embedded Resources 的透明支持,更容易将 Swagger 作为一个独立的单元进行管理和升级。

总之,您不再需要 Swagger 的资产,因为它们现在已嵌入到 dll 中。

虚拟文件系统

Virtual File System 上的文档展示了如何覆盖嵌入式资源

覆盖 Swaggers 嵌入式资源

ServiceStack 的虚拟文件系统支持多个文件源位置,您可以通过在与现有嵌入文件相同的位置包含您自己的自定义文件来覆盖 Swagger 的嵌入文件。这使您可以通过简单地复制您想要自定义的/swagger-ui/swagger-ui-bootstrap文件并将它们放在您的网站目录中相同的路径来替换内置的 ServiceStack 嵌入式资源,即:

/swagger-ui
  /css
  /images
  /lib
  index.html

/swagger-ui-bootstrap
  index.html
  swagger-like-template.html
于 2014-08-27T18:25:35.733 回答