我正在使用:
我正在尝试将swashbuckle用于odata,当我添加值控制器时出现此错误:
如果我删除了值控制器,我会大摇大摆地得到它:
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging();
services.AddOData();
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "OData API", Version = "v1" });
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
Data.Core.Repository.LoggerFactory = LoggerFactory;
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseCors();
app.UseODataBatching();
app.UseMvc(r => {
var builder = new ODataConventionModelBuilder()
{
//Namespace = "OData",
};
var eb = builder.EntitySet<Employee1>(nameof(Employee1));
eb = builder.EntitySet<Employee1>(nameof(Employee2));
eb = builder.EntitySet<Employee1>(nameof(Employee3));
var model = builder.GetEdmModel();
r.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
r.MapODataServiceRoute("odata", null, model, new DefaultODataBatchHandler());
r.EnableDependencyInjection();
});
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.RoutePrefix = "swagger";
c.SwaggerEndpoint("/swagger/v1/swagger.json", "OData API V1");
});
app.UseAuthentication();
Mapper.Initialize(cfg => {
cfg.AddProfiles(typeof(Startup));
});
}