.net Core Swagger报错 the same schemaid is already used for type swagger


AppSecretController中有P_Create类

AppSecret_RulesController中也有有P_Create类

“the same schemaid is already used for type swagger”错误的解决方案

 

Markup 全选
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate Operation for action - YESWEB.Module.MicroApps.Controllers.AppSecret_RulesController.Create (YESWEB.Module.MicroApps). See inner exception
 ---> Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate schema for type - YESWEB.Module.MicroApps.Controllers.AppSecret_RulesController+P_Create. See inner exception
 ---> System.InvalidOperationException: Can't use schemaId "$P_Create" for type "$YESWEB.Module.MicroApps.Controllers.AppSecret_RulesController+P_Create". The same schemaId is already used for type "$YESWEB.Module.MicroApps.Controllers.AppSecretController+P_Create"
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.RegisterType(Type type, String schemaId)
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateReferencedSchema(DataContract dataContract, SchemaRepository schemaRepository, Func`1 definitionFactory)
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForParameter(Type modelType, SchemaRepository schemaRepository, ParameterInfo parameterInfo, ApiParameterRouteInfo routeInfo)
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, ParameterInfo parameterInfo, ApiParameterRouteInfo routeInfo)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo parameterInfo, ApiParameterRouteInfo routeInfo)
   --- End of inner exception stack trace ---
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo parameterInfo, ApiParameterRouteInfo routeInfo)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateRequestBodyFromBodyParameter(ApiDescription apiDescription, SchemaRepository schemaRepository, ApiParameterDescription bodyParameter)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateRequestBody(ApiDescription apiDescription, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)
   --- End of inner exception stack trace ---
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerDocumentWithoutFilters(String documentName, String host, String basePath)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerAsync(String documentName, String host, String basePath)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

解决方案:

C# 全选
services.ConfigureSwaggerGen(options =>
{
	// 不加这个会报错
	options.CustomSchemaIds(x => x.FullName);
});
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
张国生
上一篇:Navicat延长试用,删除注册表无限试用
下一篇:.net core 开源API框架
评论列表

发表评论

评论内容
昵称:
关联文章

.net Core Swagger the same schemaid is already used for type swagger
WCF中常见的The content type text
.NET Core中使用编码GB2312‘GB2312‘ is not a supported encoding name 解决方案
在ASP.NET Core web API中使用Swagger/OpenAPI(Swashbuckle)
.NET Core Winform 打开窗体设计器
EFCore异步查询
.Net启动程序:It was not possible to find any compatible framework version
EF异步查询ToListAsync
.netcore 打开SQLite数据库失败:You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().”
asp.net core MVC路由添加.html伪静态url时报
.net core自动构建版本号
Python多线程中试用wmi
使用.NET 6开发TodoList应用(27)——实现API的Swagger文档化
EFCore链接数据库
.NETCore 运行项目:Could not load file or assembly ***
vue typescript 使用big.js编译build会
VS .NET使用EF添加实体数据模型向导添加连接
Cannot resolve scoped service from root provider ASP.NET Core
html发布到服务器后部分jpgnet::ERR_BLOCKED_BY_CLIENT
EF生成迁移脚本报:Entity type '' has a split mapping, but it doesn't map any non-primary key property to the main store object. Keep at least one non-primary key property mapped to a column on '.

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码