ServiceStack: No /swagger-ui/index.html

橙三吉。 提交于 2019-12-11 02:07:30

问题


I am using ServiceStack for my custom service, in stand alone mode without IIS.

I would like to add documentation for my services beyond what /metadata does. I thought to try the Swagger plug in.

I have added the plug-in command to my Config

        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());
        }

The existing services continue to work, but attempting to access

/swagger-ui/index.html

gives the not found error. Is there an additional step not clearly documented at

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

Do I have to actually set up this page myself? If so, how?


回答1:


After more research, using the servicestack.api.swagger package only installs the /resource service to query the API. It does not include any client-side resources.

To get the client-side UI, you have to download the files from the Swagger UI project on Github, and install the dist directory resources yourself.




回答2:


Adding the ServiceStack.Api.Swagger NuGet package should include all the client side resources you need. Try updating the NuGet package as all the client side resources you need should already be in /swagger-ui



来源:https://stackoverflow.com/questions/16649066/servicestack-no-swagger-ui-index-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!