Swagger and ServiceStack 4.0
本文关键字:ServiceStack and Swagger | 更新日期: 2024-10-22 06:36:46
首先,我会问我的问题,然后解释我们在测试中发现的问题。我们似乎无法使用ServiceStack 4.0访问resources
路由上的Swagger API。这仍然得到支持吗?
我们正在启动一个绿地项目,并正在调查ServiceStack。根据建议,我们使用的是http://ServiceStack.net.我们已经建立了一个"安全"服务,并验证了/Security/User/username
是否正确返回了我们关于用户的信息。ServiceStack的端到端测试运行良好。
在我们前进的过程中,我们还希望使用Swagger来记录我们的API。在我们的测试中,resources
路由在4.0版本中不再受支持,或者至少不起作用。我们已经下载了所有的示例项目作为指导,它们都使用ServiceStack 3.9.33,所以使用这些示例运气不太好。我们已经为Swagger资源快照尝试了这些本地URL:
localhost:85/resources
localhost:85/api/resources (with routing changes in the web.config
localhost:85/security/resources
localhost:85/api/security/resources (with routing changes in the web.config)
都没有运气。我们缺少什么?
这是我们的AppHost类:
public class AppHost : AppHostBase
{
public AppHost()
: base("API Services", typeof(SecurityService).Assembly)
{
}
public override void Configure(Container container)
{
Plugins.Add(new SwaggerFeature());
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(UserValidator).Assembly);
}
}
以及我们的Global.asax文件中的相关代码:
protected void Application_Start(object sender, EventArgs e)
{
new AppHost().Init();
}
我们已经获得了使用NuGet和Visual Studio 2013的所有软件包中的最新版本。欢迎为ServiceStack新手提供任何指导。
我希望解决方案比这更聪明,哪怕只是为了让我觉得我理解了问题,但通过包管理控制台删除并重新安装所有ServiceStack包解决了问题。感谢所有帮助我调试的人。