swagger

What is Swagger and does it relate to OData?

痞子三分冷 提交于 2020-12-27 12:24:49
问题 I am familiar with the Microsoft stack. I am using OData for some of my restful services. Recently I came across Swagger for API documentation and I am trying to understand how it relates to OData. Both of them seem to be RESTful specifications. Which one is widely used? 回答1: Swagger is a specification for documenting APIs . By creating a swagger document for your API, you can pass it to an instance of Swagger UI, which renders the document in a neat, readable format and provides tooling to

springboot 整合redis

五迷三道 提交于 2020-12-18 01:29:38
springboot整合redis官方是有文档的: 英文看不懂可以翻译,代码应该看得懂, 这个是自动注入的。当然也可以xml注入,手动配置。 整合步骤: pom文件: <!-- spring boot web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- 热部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <!-- mybatis --> <dependency> <groupId>org.mybatis.spring.boot</groupId>

Oh my God, Swagger API文档竟然可以这样写?

心不动则不痛 提交于 2020-12-17 14:27:11
最好的总会在不经意间出现。 “ 作为后端程序员,免不了与前端同事对接API, 一个书写良好的API设计文档可有效提高与前端对接的效率。 为避免联调时来回撕逼,今天我们聊一聊正确编写Swaager API文档的姿势。 基础Swagger用法 在 ConfigureServices 配置Swagger文档,在 Configure 启用中间件 // Install-Package Swashbuckle.AspNetCore 略 services.AddSwaggerGen( options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "EAP API", Version = "v1" }); } ); --- app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "EAP API"); }); 应用会在 /Swagger 页面加载最基础的API文档。 以一个最简单的Post请求为例, 细数这最基础Swagger文档的弊病 : [HttpPost] public async Task<bool> AddHotmapAsync([FromBody]

NestJs Swagger mixed types

可紊 提交于 2020-12-15 06:20:28
问题 I have a class that one of the properties can be string or array of strings, not sure how should I define it in swagger @ApiProperty({ description: `to email address`, type: ???, <- what should be here? required: true, }) to: string | Array<string>; update As @Youba suggeted answer I tried @ApiProperty({ description: `to email address(es)`, additionalProperties: { oneOf: [ { type: 'string' }, { type: 'Array<string>' }, ], }, required: true, }) and @ApiProperty({ description: `to email address

NestJs Swagger mixed types

本秂侑毒 提交于 2020-12-15 06:20:09
问题 I have a class that one of the properties can be string or array of strings, not sure how should I define it in swagger @ApiProperty({ description: `to email address`, type: ???, <- what should be here? required: true, }) to: string | Array<string>; update As @Youba suggeted answer I tried @ApiProperty({ description: `to email address(es)`, additionalProperties: { oneOf: [ { type: 'string' }, { type: 'Array<string>' }, ], }, required: true, }) and @ApiProperty({ description: `to email address

How to integrate Swagger with SpringDoc YAML?

心已入冬 提交于 2020-12-15 06:06:48
问题 I'm using Swagger to document my project.And I want generate the YAML doc from springdoc. But when I generate this YAML documentation the YAML dont have my Swagger doc coments. For example. I have one endpoint in my project: @ApiOperation(value = "Return a list of Pix Wallets.", httpMethod = "POST", response = DResponse.class) @PostMapping("/digital-wallet") public ResponseEntity<DResponse> getDigitalWallets(@RequestBody PixDigitalWalletRequest pixDigitalWalletRequest) { return ResponseEntity

NET core 2.0 Swagger & Enum Display

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-15 05:28:44
问题 i have the next enum : public enum DataTypes { [Description("All")] All, Man, Woman } and i want to achive next : to display decription for each enum to display the Enum Key and Value. i used this next post : swagger-ui-web-api-documentation-present-enums-as-strings I did the next code changes : in the enum, i defined : [JsonConverter(typeof(StringEnumConverter))] //this is using newton public enum DataTypes { [Description("All")] All, [Description("Male222")] Male, [Description("Female")]

Asp.Net Core 3.0 WebApi 使用Swagger

爱⌒轻易说出口 提交于 2020-12-14 01:40:53
1、安装指定版本: Swashbuckle.AspNetCore 5.0.0-rc4(目前稳定版本4.0.1在AspNetCore3.0中会报错误) 2、后台C#代码要严格格式必须加[HttpPost]或者[HttpGet] 3、Startup类中配置如下代码 public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddRazorPages(); #region Swagger配置 services.AddSwaggerGen(c => { c.SwaggerDoc( " v1 " , new Microsoft.OpenApi.Models.OpenApiInfo { Title = " My API " , Version = " v1 " }); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); }); #endregion services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest); } public void Configure

Asp.Net WebApi Swagger终极搭建

隐身守侯 提交于 2020-12-13 21:50:23
【PS:原文手打,转载说明出处, 博客园 】 关于为什么用Swagger   目前稍微有点规模的公司,已经从原先的瀑布流开发到了敏捷开发,实现前后端分离,为此后端工程师只关注写好Api即可,那程序员最讨厌的就是写Api文档了,故而产生了Swagger。 Swagger原理   Swagger就是利用反射技术遍历所有Api接口,并且从xml文件中读取注释,在利用Swagger内置的模板组合html显示至客户端实现接口可视化,并且可调用。 Asp.net WebApi Swagger集成   1:vs2017,新建web项目,选择WebApi   2:删除Views、Scripts、Models、fonts、Content、Areas目录   3:删除RouteConfig.cs、FilterConfig.cs、BundleConfig.cs   4:删除HomeController.cs   5:Global.asax中删除异常代码   6:nuget搜索Swagger,安装 Swashbuckle   7:右键项目——》属性——》生成——》输出——》勾选XML文档文件——》保存   8:修改SwaggerConfig.cs     新增方法,释放c.IncludeXmlComments(GetXmlCommentsPath());的注释(注意:例如返回值为对象,然后又不在同一个项目

.Net Core之Swagger

会有一股神秘感。 提交于 2020-12-13 08:02:39
1.项目生成xml 2.添加链接文件,并将属性设值为始终复制 3.添加swagger引用:Swashbuckle.AspNetCore 4.startup.cs配置swargger的xml来源: ConfigureServices方法添加: services.AddMvc(); services.AddOptions(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "DVM AdsPlatformProxy Service WebApi", Version = "v1.0.0.3" }); var basePath = PlatformServices.Default.Application.ApplicationBasePath; var docPath = Path.Combine(basePath, "Docs"); var docs = XMLUtil.CreateXPathDocumentsFromDirectory(docPath); docs.ForEach(xp => c.IncludeXmlComments(() => { return xp; })); });//swagger文件路径配置 services.RegisterServiceR<ILogBase,