将 Swagger 与 WCF REST 结合使用 [英] Using Swagger with WCF REST
问题描述
我有一个基于 WCF REST 的服务,我想将 Swagger 添加到其中.我已经安装了 Swagger.NET 包,我的项目使用的是 .NET 4.0.我还启用了 XML 文档等...但现在我不确定从这里开始的最佳路线.
I have a WCF REST based service that I would like to add Swagger to. I have installed Swagger.NET package, my project is using .NET 4.0. I have also enabled XML documentation, etc... but now I am not sure the best route from here.
当我启动 http://localhost/SwaggerUI/index.html
时,我得到了带有 http://YOUR-URL-HERE:PORT/api/swagger<的默认页面/代码>.我不确定这里应该放什么网址.我确实通过以下方式启用了该服务的帮助:
<standardEndpoint name="" helpEnabled="true"/>
这确实给了我丑陋的页面:http://localhost/api/help
-- 当我将它插入 Swagger 时,我得到了结果:
When i launch http://localhost/SwaggerUI/index.html
I get the default page with the http://YOUR-URL-HERE:PORT/api/swagger
. I am not sure what url should go here. I did enable help of the service via: <standardEndpoint name="" helpEnabled="true" />
which does give me the ugly page here: http://localhost/api/help
-- when i plug that into Swagger i just get the result:
200 : OK http://localhost/api/help
最好的方法是什么,我没有使用 WebApi,但如果有帮助,我有许多可用的功能.
What is the best way to proceed, i am not using WebApi but have many of the features available if that helps.
推荐答案
目前没有 Swagger for WCF 的实现.您需要按照 https://github.com/wordnik/swagger-core/wiki 中的规范来实现自己的,或者耐心等待有人为您实施.
Currently there are no implementations of Swagger for WCF. You will either need to implement your own by following the spec from https://github.com/wordnik/swagger-core/wiki, or wait patiently for someone to implement one for you.
我目前正在进行实施,但还没有完全准备好迎接黄金时段.基本规范看似简单,但将其适配到 WCF 是一个明确的挑战.
I currently have an implementation in progress, but it's not quite ready for primetime. The basic spec is deceptively simple, but fitting it to WCF is a definite challenge.
这篇关于将 Swagger 与 WCF REST 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!