2

我在没有 IIS 的独立模式下将 ServiceStack 用于我的自定义服务。

我想为我的服务添加文档/metadata。我想试试 Swagger 插件。

我已将插件命令添加到我的配置中

        public override void Configure(Funq.Container container)
        {
            SetConfig(new EndpointHostConfig()
            {
                DefaultRedirectPath = "index.html",
                DebugMode = true,
                WriteErrorsToResponse = true,

                CustomHttpHandlers =
                {
                    { HttpStatusCode.Unauthorized, new AuthorizationErrorHandler() },
                    { HttpStatusCode.Forbidden, new AuthorizationErrorHandler() },
                    { HttpStatusCode.NotFound, new AuthorizationErrorHandler() }
                }

            });

            // For automatic generation of documentation to APIs
            Plugins.Add(new SwaggerFeature());
        }

现有服务继续工作,但尝试访问

/swagger-ui/index.html

给出未找到的错误。是否有其他步骤未明确记录在

https://github.com/ServiceStack/ServiceStack/wiki/Swagger-API

我必须自己实际设置此页面吗?如果是这样,怎么做?

4

2 回答 2

1

添加ServiceStack.Api.Swagger NuGet 包应包含您需要的所有客户端资源。尝试更新 NuGet 包,因为您需要的所有客户端资源都应该已经在/swagger-ui中

于 2013-05-20T14:21:16.940 回答
1

经过更多研究,使用该servicestack.api.swagger包仅安装 /resource 服务来查询 API。它不包括任何客户端资源。

要获取客户端 UI,您必须从Github 上的 Swagger UI 项目下载文件,并自行安装dist目录资源。

于 2013-05-20T12:38:37.473 回答