swagger

Spring Security - 配置免认证访问 Swagger

孤者浪人 提交于 2020-01-26 05:47:00
Spring Boot 2.2.4.RELEASE Spring Security 5.2.1.RELEASE 新建 Spring Boot 项目,引入依赖: < project > < properties > < java.version > 1.8 </ java.version > < springfox-swagger2.version > 2.9.2 </ springfox-swagger2.version > < springfox-swagger-ui.version > 2.9.2 </ springfox-swagger-ui.version > </ properties > < dependencies > < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-security </ artifactId > </ dependency > < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-web </ artifactId > </ dependency > ..

swagger: file path in path parameter

眉间皱痕 提交于 2020-01-25 20:36:08
问题 Here is my api requirement GET http://localhost:8080/filePath/{path} For example: curl http://localhost:8080/filePath/home/users/user/one.txt Here is yaml config: parameters: - name: path in: path description: Todo description type: string required: true But I'm getting 404 error. How can I use file path in path parameter? 回答1: OpenAPI 2.0 (Swagger 2.0) and OpenAPI 3.0 do not allow you to use slashes in path parameters, so you can't do that. There's an open feature request for this: https:/

Spring MVC整合swagger

蓝咒 提交于 2020-01-25 15:29:55
Spring MVC整合swagger 添加swagger配置类 在config下新建SwaggerConfig类,配置类代码如下(类的位置只要Spring能扫描并装载到就可以,类名称也是任意的): @Configuration @EnableSwagger2 @EnableWebMvc @ComponentScan ( "com.test.wjb.www.controller" ) //controller包路径 public class SwaggerConfig { @Bean public Docket api ( ) { return new Docket ( DocumentationType . SWAGGER_2 ) . select ( ) . apis ( RequestHandlerSelectors . any ( ) ) . build ( ) . apiInfo ( apiInfo ( ) ) ; } private ApiInfo apiInfo ( ) { return new ApiInfoBuilder ( ) . title ( "对外开放接口API文档" ) . description ( "HTTP对外开放接口" ) . version ( "1.0.0" ) . termsOfServiceUrl ( "http://xxx.xxx

Springboot如何集成swagger

落爺英雄遲暮 提交于 2020-01-25 11:10:18
转自: http://www.leftso.com/blog/223.html 现在微服务已经有了很大的发展势头。微服务中常用的接口方式就是Restful风格,实际的REST规范并没有建议使用任何标准的方法来记录我们将要公开的REST api(就像SOAP的WSDL)。因此,每个人都在用自己的方式记录他们的api,这导致了通用结构上的一个缺陷,为了解决这个问题,出现了swagger,根据swagger生成的接口文档,所有人都可以很容易地理解并进行使用相应的接口。 我们将首先创建一些REST api接口,这些api接口将用于演示Swagger的文档功能。我们将使用Spring boot风格来显示rest API,以获得更快的开发时间。 1、创建spring boot项目 可以去spring boot官网创建一个web带Rest接口依赖的spring boot项目,也可以用idea工具创建。(如果) 2、修改application.properties配置文件。 添加以下属性。项目将会从 /swagger2-demo context 路径启动应用. 3、添加一个REST的contrller和实体类 创建类 Swagger2DemoRestController,他将会 为学生实体提供基本的基于REST的功能。 package com.testswagger.controller;

Upgraded spring boot from 2.1.0 to 2.2.2.RELEASE , now getting exception while starting

醉酒当歌 提交于 2020-01-25 08:24:04
问题 I am upgraded SpringBoot version 2.1.0 to 2.2.2.RELEASE java : openjdk11 spring-boot: v2.2.0.RELEASE springCloudVersion : Hoxton.RC1 Error : APPLICATION FAILED TO START Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152) The following method did not exist: org.springframework.plugin.core

极致简洁的SpringBoot整合Swagger

微笑、不失礼 提交于 2020-01-25 07:25:36
极致简洁的SpringBoot整合Swagger 借鉴 借鉴开源项目 com.spring4all.swagger-spring-boot-starter 。 依赖 < dependency > < groupId > com.spring4all </ groupId > < artifactId > swagger-spring-boot-starter </ artifactId > < version > 1.9.0.RELEASE </ version > </ dependency > 使用步骤 在启动类中添加 @EnableSwagger2Doc 注解 @EnableSwagger2Doc @SpringBootApplication public class Bootstrap { public static void main ( String [ ] args ) { SpringApplication . run ( Bootstrap . class , args ) ; } } 默认情况下就能产生所有当前Spring MVC加载的请求映射文档。 编写Controller @RestController ( "hello" ) public class HelloController { @ApiOperation ( value = "Hello

How to test error codes with swagger and dredd?

最后都变了- 提交于 2020-01-25 03:55:42
问题 Any Idea how the rest api error codes can be tested with Dredd in combination with swagger .yaml file? Is there a best practice how to test all the different errors for the paths? Example: Path /task/{id} can have 3 type of responses: 200 -> OK 404 -> Task not found 403 -> Forbidden(not your task) Is it possible to test all 3 "workflows" for this path with swagger / dredd? 回答1: It is possible with hooks. See the Choosing HTTP Transactions and Multiple Requests and Responses sections in Dredd

Control of swagger file default property

。_饼干妹妹 提交于 2020-01-25 03:50:12
问题 Using swagger-core/swagger-annotations in version 1.5.16 Have problem to control the default property in swagger file for my data model. Have a POJO that defines the input JSON object for HTTP POST: import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(description = "Parameters to use when creating my object") public class MyPrototype { @JsonProperty(value = "name")

swagger通过swagger2markup导出PDF和HTML文档

﹥>﹥吖頭↗ 提交于 2020-01-25 00:31:41
swagger通过swagger2markup导出PDF和HTML文档 本文由个人总结,如需转载使用请标明原著及原文地址 写这篇文章的主要原因是,我以前写了篇spring-boot整合swagger的文章,我文章中没有提到任何导出相关的部分,毕竟我工作中没那个需求,我自己一人写vue+spring-boot的项目,实际上连swagger都没怎么用到。 但是,但是说的才是重点,可能百度搜索的关键词在CSDN里的文章推荐里出现,导致很多人跑到我那篇文章,没看标题没看内容就留言什么“导出呢?导出呢?” “逐渐忘掉标题...” →_→ 我是很无语,好吧虽然对我没啥用,还是为键盘侠们去找个swagger导出给你们吧,这次是有“导出”两个字了,里面的坑我也基本都挖过一遍了 希望大家有时间多自己动手做做,像这个框架的坑,纯百度也才半天就能全整完,有时间的话,可以自己做做技术的整合,对你走在程序员的道路上会有很大帮助 本文主要讲通过swagger2markup导出pdf和html文档 对于不看标题的孩子们我也为你们准备了导出word文档的地址 叫爸爸 和 demo 再叫一声 ,左边两个神奇的字符是超链接,请自行看大佬们的文档,自行填坑,我个人比较讨厌10种人,一种是不看标题的,一种是看不懂中文的中国人,所以超链接才写的那么个性 先上个效果图 1.下载Swagger2Markup Demo

swagger.core的使用方法

风格不统一 提交于 2020-01-25 00:21:57
Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务,那么如何在abp中使用呢,已经有大牛为我们实现了一个swagger.core的组件而作为菜鸟的我们只需要通过简单安装配置即可使用。 1、安装   通过“程序管理包控制台进行安装,键入Install-Package Swashbuckle.Core命令即可,注意:这里的默认项目一定要是webapi这一层” 2、配置   引入名称空间 using Swashbuckle.Application; using System.Linq;   配置代码 public override void Initialize() { IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(testApplicationModule).Assembly, "app") .Build(); Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter(