swagger

swagger学习

不打扰是莪最后的温柔 提交于 2019-12-06 13:23:51
https://www.bilibili.com/video/av64841843?p=2 哔哩哔哩教学视频 springBoot集成swagger 需要的jar包 : Springfox Swagger2 和Springfox Swagger UI 1 新建项目,springBoot-web的项目 2 导入依赖 3 Hello工程 4 集成swagger 创建一个config文件夹 SwaggerConfig.java 加入注解,@Configration 注入到springboot项目中 @EnableSwagger2 开启Swagger2 4 测试(什么都没配置就是默认配置) 访问 http://localhost:8080/swagger-ui.html 二; 基本信息配置 阅读源码 首先创建一个Docket的bean实例 2 创建一个apiInfo()类,实现apiInfo()方法,swagger默认的一些文档信息 termsOfServiceUrl :就是一个url链接, 三:扫描接口等 basePackage是最常用的 测试环境下开启swagger,生产环境不开启swagger,如何做? 1判断环境 2注入enable 四:分组: .groupName("default"); 添加实体类,扫描到,只要接口的返回值是一个实体类,就能够扫描到该接口、 添加注释

Swagger - timestamp weird representation

女生的网名这么多〃 提交于 2019-12-06 11:42:16
I have Spring Boot controller and for easy API reference used Swagger. Question about timestamp . Why in generated documentation example looks like: "timestamp": { "date": 0, "day": 0, "hours": 0, "minutes": 0, "month": 0, "nanos": 0, "seconds": 0, "time": 0, "timezoneOffset": 0, "year": 0 } So why swagger have so strange example for timestamp no just simple numeric value, which standard describes this representation? check open specification of Swagger ( https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md ). If you want to solve the issue, try this sample spring boot

Swagger-PHP for generating JSON file for Swagger-UI

风流意气都作罢 提交于 2019-12-06 08:37:01
问题 I am trying to use Swagger-PHP for generating JSON files , so that I can use it with Swagger-UI for auto documentation. I tried the link :- https://github.com/zircote/swagger-php Also I tried to work around with there documentation at http://zircote.com/swagger-php/installation.html But my hard luck , I am unable to implement it. I am able to install composer correctly. Also the bundle of Swagger-PHP is installed correctly. But the problem is that I am unable to use/understand the test

Swagger.NET MVC Api Exception

守給你的承諾、 提交于 2019-12-06 08:32:08
问题 Been looking at different options for providing auto generated API Documentation and Swagger seems to be up there. However when trying this out for the first time I'm getting exceptions on start up. Running Visual Studio 2013. Create new Web API project. Using Package Manager, run: Install-Package Swagger.Net & Install-Packager Swagger.Net.UI Making sure we've enable the XML documentation we get this exception: Method 'GetDocumentation' in type 'Swagger.Net.XmlCommentDocumentationProvider'

How to define HashMap<String, List<Object>> property in swagger yml?

北城以北 提交于 2019-12-06 08:14:06
问题 I am using swagger to generate classes in Java and Type script. I have problem defining map property with list of objects as value. I tried to define as follows: DataMap type: object additionalProperties: #type: array -- This config does not work. $ref: '#/definitions/Data' Above yml definition generated following code in java: class DataMap extends HashMap<String, Data> { } How can I configure yml to generate key with list of data ? something like following class: class DataMap extends

.net webapi 使用swagger生成文档

扶醉桌前 提交于 2019-12-06 08:03:34
网上看到不少整理的,但是当我搭建的时候发现很多包在nuget中找不到了,所以特地在此写记录一下 我的项目的版本是4.5的,用的nuget包是Swagger-Net和Swashbuckle.Net45 添加完成后右键项目属性->生成->输出 勾选XML文档文件 启动项目后访问如下地址: 你的项目地址/swagger/ui/index 如图显示就正常的文档了,前提是你的代码中有注释 下边讲一下怎么在这个页面中请求接口 显示无参数的请求接口 这是有参数的使用 这场使用没问题,但是,有的接口会在header中添加一些内容进行请求头的验证,这里讲一下请求头有验证的情况下怎么设置 有过滤器ApiAuthAttribute 这里简单检查一下header中是否存在一个auth protected override bool IsAuthorized(HttpActionContext actionContext) { var authHeader = from t in actionContext.Request.Headers where t.Key == "auth" select t.Value.FirstOrDefault(); if (authHeader != null) { string token = authHeader.FirstOrDefault(); if (string

Multiple API documentation in one Swagger file

萝らか妹 提交于 2019-12-06 07:58:37
问题 Is it possible to have multiple (somehow separated) REST API documentations but only in one swagger yaml file? Or can the swagger yaml contain only one API documentation? Because I have 2 REST API developed by me, and I want to have a common swagger ui instead of two, which I could manage with a gateway like Tyk. 来源: https://stackoverflow.com/questions/51080805/multiple-api-documentation-in-one-swagger-file

Generate a Swagger file for certain endpoints from another Swagger or OpenAPI file

旧时模样 提交于 2019-12-06 07:15:42
Having one big Swagger/OpenAPI YAML specification, how can I safely extract certain API endpoints and generate a new .yaml for them exclusively? It's easy to identify API endpoints from a certain level (like defined with one indent or more): paths: /users: ... - $ref: '#/requests/getUser' /repos: ... requests: getUser: ... I'd just copy all sections, except paths , into a new specs file. And then I'd copy certain paths subsections like /users: based on indents. In Python, with a regex. But is this direct method safe for the specs? Swagger Inspector lets you make API calls and then create the

运用swagger编写api文档

可紊 提交于 2019-12-06 06:49:42
一.什么是swagger 随着互联网技术的发展,前后端技术在各自的道路上越走越远,他们之间的唯一联系变成了api接口,api接口文档编程了前后端人员的纽带,而swagger就是书写api文档的一款框架. 官网: https://swagger.io/ 相关资源下载地址: https://download.csdn.net/download/zhixingwu/12008773 推荐: 也可以使用 showdoc来书写api文档. 官网: https://www.showdoc.cc/ 二.SwaggerEditor的安装与启动 下载 swagger-editor.zip 解压swagger-editor 全局安装http-server(http-server是一个简单的零配置命令行http服务器) npm install ‐g http‐server 启动swagger-editor http‐server swagger‐editor 浏览器打开: http://localhost:8080 三.语法规则 1.固定字段 字段名 类型 描述 swagger string 必需的。使用指定的规范版本 info info Object 必需的。提供元数据API host string 主机名或ip服务API basePath string API的基本路径 schemes