springfox

Sping Data REST Endpoints Not Generating In Swagger UI

本秂侑毒 提交于 2019-12-13 04:16:35
问题 I've implemented a controller using @BasePathAwareController which also takes advantage of Spring Data REST (for finds to expose sort/size etc.) along with some custom endpoints (for updates etc.). The application is working as expected and the endpoints Spring Data REST generates are working as expected and I can see the self links appear in the responses, however, i can't see these endpoints in Swagger UI. I can just see my custom endpoints defined in my Controller. According to this post I

Hypermedia links in Swagger UI using Springfox

☆樱花仙子☆ 提交于 2019-12-13 02:36:16
问题 I'm building a RESTful API, using spring-hateoas library to implement hypermedia. The response of my endpoints is application/hal+json (My DTO extends ResourceSupport). I'm using Swagger to document the endpoints, and using Springfox to autogenerate the swagger-ui. The problem is, that the generated documentation is not correct. As a request for a POST endpoint, the UI is setting the _links section from my DTO as part of the payload, so this is what I see I should send as a parameter for my

springboot+swagger企业开发实战(10年java老鸟经验)

孤街浪徒 提交于 2019-12-13 00:19:34
一句话概括:对于产品开发,特别是前后端分离的开发模式,接口文档是连接前后端的枢纽,本文对springboot+swagger在企业的实践进行详细描述。 1.引言 在软件开发过程中,接口设计与接口文档编写是重要的一环,特别是在前后端分离的情况下,接口说明文档是开发人员之间的连接点。接口文档的编写有很多方式,可以使用word,也可以使用编写工具如小幺鸡,这些基本属于脱离代码编写的文档,如果接口变化,需要额外修改文档,增加工作量。如何提高写接口文档效率,在springboot开发中,结合swagger来提供接口文档说明是一个很好的实践,通过配置与注解,在编写接口代码过程中,同时也把接口文档写好,接口需要变更时,文档也同时变更,具有工作量少,效率高,接口文档直观简洁,可实时调用验证等好处。本文基本springboot2+swagger2,结合在企业中的实践,对接口文档的编写进行详细说明,具体有如下内容: swagger介绍及文档生成说明 使用springboot2+swagger2构建示例工程及配置描述 使用注解添加文档内容说明 使用全局参数进行接口认证 如需看源码,本文示例工程地址: https://github.com/mianshenglee/my-example 2.swagger简介 2.1 swagger 介绍 swagger官网地址: https://swagger.io

springfox hide allowEmptyValue when field annotated with @ApiModelProperty

断了今生、忘了曾经 提交于 2019-12-12 19:24:08
问题 How can I hide the allowEmptyValue description of response type on swagger-ui.html. springfox version: 2.8.0 springfox-ui version: 2.8.0 回答1: Maybe a customized property builder plugin can help, try to set allowEmptyValue to null . import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition; import com.google.common.base.Optional; import io.swagger.annotations

Springfox - Is it possible to document a POJO via annotation if it's not used in a controller

喜欢而已 提交于 2019-12-12 19:12:45
问题 As the title says, is it possible to include a POJO in a swagger doc if it's not used in a controller method? I've tried using the @ApiModel annotation on the POJO class, i.e.: @ApiModel("POJO") public class Pojo { ... } However, unless the POJO is returned by a controller, I haven't been able to have it appear in the generated swagger docs. Is there a way to accomplish this? I'm using springfox version 2.9.2, by the way. 回答1: It is possible with Springfox. You just have to modify your Docket

Springfox swagger-ui.html unable to infer base URL - Caused by missing cookies

心不动则不痛 提交于 2019-12-12 09:33:49
问题 We have our Spring Boot services behind an API Gateway. With an earlier version of Springfox - 2.1.2 we had no issues in loading the swagger-ui.html page. This worked with Spring Boot 1.4.3.RELEASE. From then, we have upgraded to Boot 1.5.7 and upgraded Springfox to 2.8.0. Now if we load the page we get an alert box with the following long message. Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the

Springfox-Swagger2 406 not acceptable error -Spring 4

可紊 提交于 2019-12-12 04:29:59
问题 Hi I am getting "The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers" error i.e Http 406 not acceptable. I am using the below dependencies for swagger <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.0.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId>

Swagger Version for Spring 3 and Spring 4

℡╲_俬逩灬. 提交于 2019-12-12 02:46:01
问题 I want to documenting a REST API with Swagger and Spring MVC, And I find out that Spring 3 only can use Swagger V1 <artifactId>swagger-springmvc</artifactId> <version>1.0.2</version> when I add @ApiParam in front of @RequestBody , do not display completely in Data Type. Finally I choose Swagger V2 in Spring 4 I add some dependency and change, as below . <artifactId>springfox-swagger2</artifactId> <version>2.2.2</version> <artifactId>spring-web</artifactId> <artifactId>4.1.6.RELEASE<

Spring Webflux annotated rest controller doesn't support ServerHttpRequest as method parameter: java.lang.NoSuchMethodException

心已入冬 提交于 2019-12-11 08:32:01
问题 Spring Boot 2.1.0/1 application packaged as war doesn't support ServerHttpRequest as input parameter in a Rest Controller, e.g: @GetMapping(produces = APPLICATION_JSON_UTF8_VALUE) public Flux<Event> findAll(ServerHttpRequest request) { return eventService.findAll(); } Log: java.lang.IllegalStateException: No primary or default constructor found for interface org.springframework.http.server.reactive.ServerHttpRequest at org.springframework.web.method.annotation.ModelAttributeMethodProcessor

Generate Swagger from a JSON to keep clean my .java classes

ⅰ亾dé卋堺 提交于 2019-12-11 07:44:33
问题 I am using Springfox v 2.7 and I'd like to generate my Swagger UI from a JSON file, to keep my Controller classes clean, and without annotations from Swawgger (@Api, @ApiDocs) either my model classes without any annotation (@ApiModelProperty, etc).... Regards! PD: This is a Spring boot 1.5.8 version App. 回答1: Here are the changes you need to make: Only Springfox JAR needed is springfox-swagger-ui JAR which contains all the static UI artifacts. A swagger.json file containing all the JSON