-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Paths' is required. #145
Comments
Could you provide more information about your sample ? Based on your steps , I can get the result as follow , {
"swagger": "2.0",
"info": {
"title": "thing api",
"description": "thing.ly",
"contact": {
"url": "http://thing/support",
"email": "support@thing"
},
"version": "v1.5"
},
"paths": {
"/ping": {
"get": {
"summary": "Ping",
"description": "",
"operationId": "Ping",
"responses": {
"200": {
"description": "OK"
}
}
},
"parameters": [ ]
}
}
} |
Example Repo: https://github.com/LucasMoffitt/nancy.swagger.test It's as close to the configuration I have now as possible. It's clearly an issue on my end, I just honestly can't see it. What am I doing wrong? Get: /api-docs |
So I've been trying for an hour and I can't seem to get your sample code to work either. However, I was able to get your module to produce the paths by using Nancy.Swagger.Annotations. (It's possible that Autofac was never working with the base Nancy project, because we originally tested and created the sample using annotations) |
@jnallard Thanks for validating, i've been slowly going insane. Looking here: https://github.com/yahehe/Nancy.Swagger/blob/master/src/Nancy.Swagger/Services/DefaultSwaggerMetadataProvider.cs#L27 No metadata is available in the routeCacheProvider.GetCache(). |
@LucasMoffitt, thanks! My debugger in VS was really not doing what I expected today, so I didn't get too far. If that's the case, then it makes sense that the Annotations project still works, because it doesn't use that cache to get the module information. I can look into it more soon. |
@LucasMoffitt You need to change the name from //public class Home : NancyModule
public class HomeModule : NancyModule
{
//public Home(IMediator mediator)
public HomeModule(IMediator mediator)
{
//...
}
} 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 Module and 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 ! |
Thanks for your help @catcherwong @jnallard @yahehe, appreciate it! |
I'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 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
The text was updated successfully, but these errors were encountered: