'Paths' is required.
See original GitHub issueI’ve followed the instructions here and looked at the Autofac / default samples, but I still continue to get 'Path’s is required:
{ "ClassName": "Swagger.ObjectModel.Builders.RequiredFieldException", "Message": "'Paths' is required.", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": " at Swagger.ObjectModel.Builders.SwaggerRootBuilder.Build()\r\n at Nancy.Swagger.Services.SwaggerMetadataProvider.GetSwaggerJson(NancyContext context)\r\n at Nancy.Swagger.Modules.SwaggerModule.<>c__DisplayClass0_0.<.ctor>b__0(Object _)\r\n at Nancy.NancyModule.<>c__DisplayClass14_0'1.<Get>b__0(Object args)\r\n at Nancy.NancyModule.<>c__DisplayClass16_0'1.<Get>b__0(Object args, CancellationToken ct)\r\n at Nancy.Routing.Route'1.Invoke(DynamicDictionary parameters, CancellationToken cancellationToken)\r\n at Nancy.Routing.DefaultRouteInvoker.<Invoke>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Nancy.Routing.DefaultRequestDispatcher.<Dispatch>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Nancy.NancyEngine.<InvokeRequestLifeCycle>d__22.MoveNext()", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": "8\nBuild\nSwagger.ObjectModel, Version=2.2.42.0, Culture=neutral, PublicKeyToken=null\nSwagger.ObjectModel.Builders.SwaggerRootBuilder\nSwagger.ObjectModel.SwaggerRoot Build()", "HResult": -2146233079, "Source": "Swagger.ObjectModel", "WatsonBuckets": null }
I add the following to my bootstrapper:
SwaggerMetadataProvider.SetInfo("thing api", "v1.5", "thing.ly", new Contact { EmailAddress = "support@thing", Url = "http://thing/support" });
And I add names to my Nancy module routes
Get("/ping", _ => { this.RequiresAuthentication(); return HttpStatusCode.OK; }, null, "Ping");
I created a class and ensured that it’s <Home>MetadataModule and in the same namespace as “Home” public class HomeMetadataModule : SwaggerMetadataModule { public HomeMetadataModule(ISwaggerModelCatalog modelCatalog, ISwaggerTagCatalog tagCatalog) : base(modelCatalog, tagCatalog) { RouteDescriber.DescribeRoute("Ping", "", "Ping", new[] { new HttpResponseMetadata {Code = 200, Message = "OK"} }); } }
I hit run, head to /api-docs and I’m still getting the ‘Paths’ is required message.
I’m running vs 2015 so haven’t tried to debug the demos of yet.
Version: Nancy.Swagger 2.2.42-alpha
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
@LucasMoffitt I check your sample and find out the problem .
You need to change the name from
Home
toHomeModule
, and after changing , you will get the result !For more details , you can visit DefaultMetadataModuleConventions to find more information !
Oof that’s a gnarly error for such a seemingly simple thing.
We do have it documented that it should be <blah>Module and <blah>MetadataModule in the wiki, but obviously this error is less than ideal. Let’s keep this issue open and I’ll think about some other ways we can handle this. In the meantime, rename Home as Catcher suggested and you should be able to move forward.
Thanks for your help @catcherwong and @jnallard !