C#添加WebApi,配置Swagger

1、创建一个WebAPI项目

下载、安装、引入【Swashbuckle.AspNetCore】包

右击【解决方案】,然后点击【管理Nuget包】,搜索【Swashbuckle.AspNetCore】包

2、配置Swagger中间件

在【Startup.cs】文件中的【ConfigureService】类中添加如下代码。

在【Startup.cs】文件中的【Configure】类中启用Swagger中间件

3、运行项目

WebApi配置正确

Swagger配置正确

swagger/index.html配置正确

4、设置默认直接到swagger界面

5、启用XML注释

startup中增加xml解析

相关推荐
一念一花一世界3 天前
接口管理工具选型指南:Postman vs swagger vs PostIn
postman·swagger·postin·接口管理工具
没有bug.的程序员5 天前
Spring Boot 与 Swagger:API 文档自动化生成、版本管理与云原生协作深度实战指南
spring boot·云原生·自动化·api·swagger·版本管理·自动化生产
wstcl8 天前
像asp.net core webapi一样在asp.net frameworks中使用Swagger,方便调试接口
后端·asp.net·swagger·webapi
spencer_tseng13 天前
Trying to infer dataType org.springframework.ui.ModelMap
swagger
Zsh-cs16 天前
苍穹外卖之Swagger+Knife4j在项目中的应用场景
swagger·knife4j·苍穹外卖
多则惑少则明1 个月前
SpringBoot3整合knife4j(swagger3)
java·spring boot·swagger
秋雨雁南飞2 个月前
C# SignalR 添加Swagger
c#·swagger·signalr
xiaoid2 个月前
C#向jave平台的API接口推送
c#·post·webapi
召田最帅boy2 个月前
Swagger使用教程
swagger
闲人编程2 个月前
OpenAPI/Swagger规范与API文档自动化
运维·自动化·json·swagger·schema·openapi·codecapsule