Using Nancy v 1.4.1 and Nancy.Swagger v 2.1.1 (the last one that supports Nancy v1), I get the above error when navigating to the /api-docs path. Any ideas? No setup steps I've seen says anything about the 'Paths' field.
My Module:
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";
};
}
}
My Module metadata:
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")));
}
}
Stack Trace:
Nancy.RequestExecutionException: Oh noes! ---> Swagger.ObjectModel.Builders.RequiredFieldException: 'Paths' is required. at Swagger.ObjectModel.Builders.SwaggerRootBuilder.Build() in C:\projects\nancy-swagger\src\Swagger.ObjectModel\Builders\SwaggerRootBuilder.cs:line 123 at Nancy.Swagger.Services.SwaggerMetadataProvider.GetSwaggerJson() in C:\projects\nancy-swagger\src\Nancy.Swagger\Services\SwaggerMetadataProvider.cs:line 91 at Nancy.Swagger.Modules.SwaggerModule.<>c__DisplayClass0_0.<.ctor>b__0(Object _) in C:\projects\nancy-swagger\src\Nancy.Swagger\Modules\SwaggerModule.cs:line 11 at CallSite.Target(Closure , CallSite , Func`2 , Object ) at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context) --- End of inner exception stack trace --- at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)
You have it in wrong order - name should be first, then path
Get["Home", "/"] = parameters => //this is right
{
try
{
return "home";// View["view/index.html"];
}
catch (Exception ex)
{
return ExceptionHelper.ExceptionResponse(Negotiate, ex);
}
};
Get["Test", "/test/"] = parameters => { //and this is right
return "testie";
};