yahehe / Nancy.Swagger

Nancy plugin for generated API documentation in Swagger format.
MIT License
133 stars 60 forks source link

Could not resolve reference because of: Could not resolve pointer #124

Closed digitalmedia34 closed 7 years ago

digitalmedia34 commented 7 years ago

I am getting this error "Could not resolve reference because of: Could not resolve pointer" looking at the error log it says Could not resolve reference because of: Could not resolve pointer: /definitions does not exist in document. Is there something extra that needs to be added to nancy??

Thanks

yahehe commented 7 years ago

Yeah you're going to need to be a lot more descriptive of the problem

jnallard commented 7 years ago

My best guess is that no models (the classes you are transferring) were added to your swagger document. Nancy.Swagger will not automatically describe all of your nancy routes. You need to specify which ones and provide the models for Swagger.

If that's your problem or if it's something else related to configuration, then I recommend looking at the samples: https://github.com/yahehe/Nancy.Swagger/tree/master/samples They will show you what's needed for Nancy.Swagger to work, (notice that there are a couple different approaches you can take). I recommend downloading them and trying them out if you're still stuck!

The Wiki also has important information on getting started: https://github.com/yahehe/Nancy.Swagger/wiki/Nancy.Swagger-for-Nancy-v2

And as @yahehe said, we need more information if we're going to help debug more! Like the version of Nancy and Nancy.Swagger you're using and what exactly through the error. (That error looks like something thrown from the swagger html page?)

digitalmedia34 commented 7 years ago

Hi, thank for you suggestions. I went through the examples with a fine comb and the issue seems to be related to container. I am using Autofac but not TinyIoc container. It means I would need to register the components manually, instead of TinyIOC which just registers everything.

Having said that the following entries fixed my issues. Note I am using Swagger.Annotations

builder.RegisterType<DefaultSwaggerModelCatalog>().As<ISwaggerModelCatalog>(); builder.RegisterType<DefaultSwaggerTagCatalog>().As<ISwaggerTagCatalog>(); builder.RegisterType<SwaggerAnnotationsProvider>().As<ISwaggerMetadataProvider>();

            builder.RegisterAssemblyTypes(Assembly.GetEntryAssembly())
                .Where(t => typeof(ISwaggerModelDataProvider).IsAssignableFrom(t))
                .InstancePerLifetimeScope()
                .AsImplementedInterfaces();

            builder.RegisterAssemblyTypes(Assembly.GetEntryAssembly())
                .Where(t => typeof(ISwaggerTagProvider).IsAssignableFrom(t))
                .InstancePerLifetimeScope()
                .AsImplementedInterfaces();

Note: Nancy.Swagger.Annotations 2.2.0-alpha (has issues) but the one in git repo works fine.