2013-12-16 57 views
4

首先,我会问我的问题,然后解释我们在测试过程中发现的问题。我们似乎无法使用ServiceStack 4.0访问resources路由上的Swagger API。这仍然是支持的吗?Swagger和ServiceStack 4.0

我们正在开始一个新建项目,并正在调查ServiceStack。按照建议,我们使用http://ServiceStack.net版本4.0。我们已经建立了一个“安全”服务,并验证/Security/User/username正确返回有关用户的信息。端到端的ServiceStack测试工作得很好。

,在我们前进,我们也想用扬鞭来记录我们的API。它出现在我们的测试中,版本4.0中不再支持resources路由,或者至少不工作。我们已经下载了所有示例项目的指导,他们都使用ServiceStack 3.9.33,所以使用示例没有太多的运气。我们已经尝试使用这些本地URL作为Swagger资源快照:

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新手的指导表示赞赏。

+0

你启用扬鞭插件在你的'AppHost'?这个细节很容易错过。下面是你在你的'AppHost.Configure'方法需要的东西:'Plugins.Add(新SwaggerFeature());' –

+1

您也可以访问'/ metadata'页在Web浏览器,你应该看到'ResourceRequest'和'资源“操作,如果Swagger配置正确。 –

+0

是的,我在AppHost中配置了该功能。我的元数据页中没有看到ResourceRequest或资源。我看到的只有我的3个操作。我用相关的代码更新了这个问题。 – mohrtan

回答

3

我希望的解决方案是比这更聪明,如果只让我觉得我理解的问题,但在移除,然后通过包管理控制台重新安装所有ServiceStack包解决的问题。感谢所有帮助我调试的人。