将 Swagger 与 WCF REST 一起使用 [英] Using Swagger with WCF REST

查看:25
本文介绍了将 Swagger 与 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.

推荐答案

目前没有针对 WCF 的 Swagger 实现.您将需要按照 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆