springfox

Why is v2/api-docs the default URL when using springfox and Swagger2?

空扰寡人 提交于 2019-11-29 05:31:07
问题 I'm just starting using swagger following this guide, but I found out something very weird that makes no sense for me. As far as I remember , the v2/api-docs should be used for when you have docs of the version number 2 of your API. So, the default should be only api-docs, but for some strange reason I found that the default is v2/api-docs. Checking the library doc I found this. How do I override that value without later not being able to use v2? (when my API will reach a v2 but I will also

swagger使用详解

自闭症网瘾萝莉.ら 提交于 2019-11-29 02:10:03
1:认识Swagger Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法,参数和模型紧密集成到服务器端的代码,允许API来始终保持同步。 作用: 1. 接口的文档在线自动生成。 2. 功能测试。 Swagger是一组开源项目,其中主要要项目如下: 1. Swagger-tools :提供各种与Swagger进行集成和交互的工具。例如模式检验、Swagger 1.2文档转换成Swagger 2.0文档等功能。 2. Swagger-core : 用于Java/Scala的的Swagger实现。与JAX-RS(Jersey、Resteasy、CXF...)、Servlets和Play框架进行集成。 3. Swagger-js : 用于JavaScript的Swagger实现。 4. Swagger-node-express : Swagger模块,用于node.js的Express web应用框架。 5. Swagger-ui :一个无依赖的HTML、JS和CSS集合,可以为Swagger兼容API动态生成优雅文档。 6. Swagger-codegen :一个模板驱动引擎,通过分析用户Swagger资源声明以各种语言生成客户端代码。 2:Maven

Swagger使用总结

ぃ、小莉子 提交于 2019-11-29 01:47:27
Swagger使用总结https://www.cnblogs.com/h9527/p/5506956.html 1. Swagger是什么? 官方说法:Swagger是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法,参数和模型紧密集成到服务器端的代码,允许API来始终保持同步。 个人觉得,swagger的一个最大的优点是能实时同步api与文档。在项目开发过程中,发生过多次:修改代码但是没有更新文档,前端还是按照老旧的文档进行开发,在联调过程中才发现问题的情况(当然依据开闭原则,对接口的修改是不允许的,但是在项目不稳定阶段,这种情况很难避免)。 2. spring boot 集成 Swagger 目前维护的系统是基于springboot框架开发的,因此本文会详细描述springboot与swagger集成的过程。 spring-boot系统集成swagger需要进行如下操作: 添加maven依赖,需要在系统的pom中添加如下依赖: gradle:compile('io.springfox:springfox-swagger2:2.2.2') <dependency> <groupId>io.springfox</groupId> <artifactId>springfox

Using @RequestParam annotated method with swagger ui

我怕爱的太早我们不能终老 提交于 2019-11-28 23:06:19
I am using Springfox libraries to generate documentation for REST service and display it in Swagger UI. I followed the directions in Springfox documentation . I have one controller, which uses parameters from query string and the method is mapped as following: @ApiOperation(value = "") @RequestMapping(method = GET, value = "/customcollection/{id}/data") public Iterable<CustomeType> getData(@ApiParam(value = "The identifier of the time series.") @PathVariable String id, @ApiParam(name = "startDate", value = "start date", defaultValue = "") @RequestParam("startDate") String startDate, @ApiParam

SpringBoot 通过配置禁用swagger

会有一股神秘感。 提交于 2019-11-28 22:15:01
转自: https://blog.csdn.net/weixin_37264997/article/details/82762050 一、序言 在生产环境下,我们需要关闭swagger配置,避免暴露接口的这种危险行为。 二、方法: 禁用方法1: 使用注解 @Value() 推荐使用 1 package com.dc.config; 2 3 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 4 import org.springframework.context.annotation.Bean; 5 import org.springframework.context.annotation.Configuration; 6 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 7 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 8 import org.springframework.web.servlet.config.annotation

swagger @ApiModelProperty example value for List<String> property

心不动则不痛 提交于 2019-11-28 21:04:46
I have one class in which there is one property which is List<String> public class MyClass { .... @ApiModelProperty(position = 2) private List<String> productIdentifiers; .... } This code generates the example values as following: { "customerId": "1001", "productIdentifiers": [ "string" ], "statuses": [ "NEW" ] } The example values here shown are not valid. My expected example values should be like : { "customerId": "1001", "productIdentifiers": [ "PRD1", "PRD2", "PRD3" ], "statuses": [ "NEW" ] } I have tried passing example attribute as following but it is not generating proper value:

Spring + Springfox + Header Parameters

谁都会走 提交于 2019-11-28 16:46:21
问题 @RequestMapping(...) public Foo getFoo(@HeaderParam("header") final String header) { ... } Adding a @HeaderParam method parameter as above springfox picks it up and when I look at the swagger-ui it has a field for the header. This is exactly what I want. Is there a way I can tell springfox to include this header parameter on a set of methods without having to include the parameters on the method itself? What we really have going on is a servlet filter which uses the header and we'd like an

swagger结合shiro如何配置

让人想犯罪 __ 提交于 2019-11-28 10:25:57
为了节省开发人员的时间与成本,swagger插件油然而生,省去您写开发文档的时间好好去快乐的玩耍,不说废话,接下来我将使用github上比较受欢迎的swagger-bootstrap-ui插件进行说明讲解,可能与swagger在配置上有所不同,但是原理差不过,只是在资源文件的 过滤 方面有所 不同 ,特别是结合了 过滤 spring security或者是 shiro 的有尤为注意: 添加依赖 <properties> <java.version>1.8</java.version> <shiro.version>1.4.0</shiro.version> <swagger2.version>2.9.2</swagger2.version> </properties> <!--swagger api文档 start--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${swagger2.version}</version> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion

Swagger API Operations Ordering

こ雲淡風輕ζ 提交于 2019-11-28 07:37:40
问题 How do I sort my operation by method alphabetically e.g. DELETE , GET , POST , PUT . I have read from this post but it is in HTML but in my case, I have integrated Swagger into Spring Boot so I need to sort it when creating a Docket. Sort API methods in Swagger UI Then I noticed this method operationOrdering() in Docket, but I still cannot make it work. 回答1: I am using Springfox version 2.8.0 and following code snippet works for my documented API: @Bean UiConfiguration uiConfig() { return

SpringBoot集成swagger

我是研究僧i 提交于 2019-11-28 05:03:17
1、在pom.xml中引用swagger依赖包 io.springfox springfox-swagger2 2.6.1 io.springfox springfox-swagger-ui 2.6.1 2、创建swager配置类 package com.vk.liyj.config; import io.swagger.annotations.ApiOperation; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo;