[英]How do I view my Swagger docs when using SwaggerWcf?
I'm trying to use swaggerwcf to add Swagger to my WCF REST API.我正在尝试使用swaggerwcf将 Swagger 添加到我的 WCF REST API。
I've followed the instructions, but I don't know what URL to use to view my Swagger documentation.我已按照说明进行操作,但我不知道要使用什么 URL 来查看我的 Swagger 文档。 I've tried:
我试过了:
http://myservername/api-docs http://myservername/api-docs
http://myservername/api-docs/index.html http://myservername/api-docs/index.html
http://myservername/api-docs/swagger.json http://myservername/api-docs/swagger.json
These all result in "Request Error", "The server encountered an error processing the request. Please see the service help page for constructing valid requests to the service."这些都会导致“请求错误”、“服务器在处理请求时遇到错误。请参阅服务帮助页面以构建对服务的有效请求。”
It dependents on what code you have written in global.asax.这取决于您在 global.asax 中编写的代码。
For example, my code in global.asax is例如,我在 global.asax 中的代码是
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add(new ServiceRoute("RegistrationService/api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
}
Then I should visit http://localhost:62193/RegistrationService/api-docs ( http://localhost:62193 is my root path).然后我应该访问http://localhost:62193/RegistrationService/api-docs ( http://localhost:62193是我的根路径)。
Also, please ensure you have configured web.xml.另外,请确保您已配置 web.xml。
<service name="SwaggerWcf.SwaggerWcfEndpoint">
<endpoint address="" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint"></endpoint>
</service>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Then if you input http://localhost:62193/RegistrationService/api-docs/ , it will redirect you to http://localhost:62193/RegistrationService/api-docs/index.html?url=/RegistrationService/api-docs/swagger.json#!/Books/Service_BookStore_ReadBooks然后,如果您输入http://localhost:62193/RegistrationService/api-docs/ ,它会将您重定向到http://localhost:62193/RegistrationService/api-docs/index.html?url=/RegistrationService/api-docs /swagger.json#!/Books/Service_BookStore_ReadBooks
Still its not displaying method info on swagger仍然没有显示 swagger 上的方法信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.