Skip to content

Unable to integrate Odata versioned apis with swagger for Asp.net web application #302

Closed
@vanikulkarniAtFIS

Description

@vanikulkarniAtFIS

We are using VersionedODataModelBuilder in Http application ( Asp.net web application)
Its does not have Owin startup hence we pass GlobalConfiguration.Configuration to VersionedODataModelBuilder constructor
Versiong of OData uri works fine as shown in the SwaggerODataWebApiSample
But while integrating this with swagger gives problems:

we create exploere as

var apiExplorer = configuration.AddODataApiExplorer(
options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});

The exception comes at
foreach (var group in apiExplorer.ApiDescriptions)
here apiExplorer.ApiDescriptions throws excpetion Invalid Operation exception
HttpConfiguration.Services.GetApiExplorer "This operation is not supported by 'HostedHttpRouteCollection'."
apiExplorer.ApiDescriptions: This operation is not supported by 'HostedHttpRouteCollection'.

The reasons could be : GlobalConfiguration.Configuration.Routes is a collection of HostedHttpRoutes
whereas in sample application we create new HttpConfigutation
Routes = {System.Web.Http.HttpRouteCollection}
vs
Routes = {System.Web.Http.WebHost.Routing.HostedHttpRouteCollection}
We also have normal ( non-odata) web apis as well

Swagger documentation is configured for them too.
Do you have any such example where odata versioning integrated with swagger and its not Owin

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions