rbeauchamp / Swashbuckle.OData

Extends Swashbuckle with OData v4 support!
Other
129 stars 96 forks source link

Added configuration to Web API and OData project throws a NullReferenceException #160

Closed aibars closed 4 years ago

aibars commented 7 years ago

Hi,

I have the following question. I have a normal versioned Web API application which I have added recently some OData controllers to it. Such controllers work fine. The solution also has Swashbuckle configured. I now want to be able to list the OData controllers and endpoints as well. The problem is that after adding the configuration on the example here, I'm getting a NullReferenceException on the following line from HttpConfigurationExceptions in the GetODataRootContainer method:

return (IServiceProvider)GetODataRootContainerMethod.Invoke(null, new object[] {configuration, oDataRoute.PathRouteConstraint.RouteName});

It seems that the oDataRoute.PathRouteConstraint is null. Could you tell me what am I doing wrong? The app does not use OWIN.

Here's my Swagger config:

GlobalConfiguration.Configuration
                .EnableSwagger(c =>
                    {
                        c.MultipleApiVersions(
                            (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion),
                            (vc) =>
                            {
                                vc.Version("v1", "API v1");
                            });

                        c.CustomProvider(defaultProvider => new ODataSwaggerProvider(defaultProvider, c, GlobalConfiguration.Configuration).Configure(odataConfig =>
                        {
                            odataConfig.IncludeNavigationProperties();
                        }));
                    })

Thank you. Agustín

AbhishekKamble commented 5 years ago

Hi,

Did you find any solution for path root constraint null exception problem.

Regards, Abhishek.

aibars commented 5 years ago

HI Abhishek,

I'm sorry, but we stopped using OData on the project I'm working on approximately a year ago. So, I didn't insist too much on this after I had this issue.

Thank you

SupportNegometal commented 5 years ago

Hi,

Bump, we are facing the same issue :(