【发布时间】:2017-09-15 09:24:01
【问题描述】:
使用 Nancy v 1.4.1 和 Nancy.Swagger v 2.1.1(支持 Nancy v1 的最后一个),导航到 /api-docs 路径时出现上述错误。有任何想法吗?我没有看到任何设置步骤说明“路径”字段。
我的模块:
public class General : NancyModule
{
public General()
{
Get["/","Home"] = parameters =>
{
try
{
return "home";// View["view/index.html"];
}
catch (Exception ex)
{
return ExceptionHelper.ExceptionResponse(Negotiate, ex);
}
};
Get["/test/", "Test"] = parameters => {
return "testie";
};
}
}
我的模块元数据:
public class GeneralMetadataModule : MetadataModule<PathItem>
{
public GeneralMetadataModule(ISwaggerModelCatalog modelCatalog)
{
Describe["Test"] = description => description.AsSwagger(
with => with.Operation(
op => op.OperationId("Test")
.Tag("Users")
.Summary("The list of users")
.Description("This returns a list of users from our awesome app")));
}
}
堆栈跟踪:
Nancy.RequestExecutionException:哦不! ---> Swagger.ObjectModel.Builders.RequiredFieldException: 'Paths' 是必需的。 在 C:\projects\nancy-swagger\src\Swagger.ObjectModel\Builders\SwaggerRootBuilder.cs:line 123 中的 Swagger.ObjectModel.Builders.SwaggerRootBuilder.Build() 在 C:\projects\nancy-swagger\src\Nancy.Swagger\Services\SwaggerMetadataProvider.cs:line 91 中的 Nancy.Swagger.Services.SwaggerMetadataProvider.GetSwaggerJson() 在 C:\projects\nancy-swagger\src\Nancy.Swagger\Modules\SwaggerModule.cs:line 11 中的 Nancy.Swagger.Modules.SwaggerModule.c__DisplayClass0_0.<.ctor>b__0(Object _) 在 CallSite.Target(闭包,CallSite,Func`2,对象) 在 Nancy.Routing.Route.c__DisplayClass4.b__3(对象参数,CancellationToken 上下文) --- 内部异常堆栈跟踪结束 --- 在 Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)
【问题讨论】:
标签: asp.net swagger swagger-ui nancy