swagger

How to change Swagger-ui URL prefix?

有些话、适合烂在心里 提交于 2019-12-18 03:44:41
问题 I am using Springfox Swagger2 with Spring boot 1.5.9. I can access swagger UI on this link. http://localhost:8090/swagger-ui.html How can I change it to be available on following URL? http://localhost:8090/my/custom/path/swagger-ui.html @EnableSwagger2 public class Configuration { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("my.favorite.package")) .paths(PathSelectors.any()) .build() .apiInfo(apiInfo())

Array of objects as an input parameter in swagger

柔情痞子 提交于 2019-12-18 02:58:24
问题 I'm trying to describe the following post parameter in swagger: { "sources": [ { "id": 101, "parentId": 201 },{ "id": 102, "parentId": 201 },{ "id": 102, "parentId": 202 } ], "destinationId": 301, "param1": "value 1", "param2": "value 2", } The issue is that the sources is an array of objects, that swagger does not seem to support. Here is what I tried: paths: /bulk-action: post: parameters: - name: sources in: formData type: array enum: $ref: '#/definitions/BulkSource' - name: destinationId

Replace Swashbuckle UI completely

爷,独闯天下 提交于 2019-12-18 02:48:30
问题 Right now I'm developing an ASP.Net Web API and using Swashbuckle for its documentation. I know that Swashbuckle use Swagger-UI internally, I know that we can modify the layout by injecting our css or javascript file, even change the layout of index.html. I found a good themes for Swagger-UI https://github.com/jensoleg/swagger-ui and trying to implement it but can't make it works. Especially when I want to inject bootstrap.js. Is there anyway I can completely change Swashbuckle Swagger UI

swagger的使用

时光毁灭记忆、已成空白 提交于 2019-12-18 02:41:27
传统文档的痛点 对API文档进行更新的时候,需要通知前端开发人员,导致文档更新交流不及时; API接口返回信息不明确 大公司中肯定会有专门文档服务器对接口文档进行更新。 缺乏在线接口测试,通常需要使用相应的API测试工具,比如postman、SoapUI等 接口文档太多,不便于管理 Swagger具有以下优点 功能丰富:支持多种注解,自动生成接口文档界面,支持在界面测试API接口功能; 及时更新:开发过程中花一点写注释的时间,就可以及时的更新API文档,省心省力; 整合简单:通过添加 pom 依赖和简单配置,内嵌于应用中就可同时发布API接口文档界面,不需要部署独立服务。 使用springboot的集成 后面会又springCloud的和zuul整合进行文档的管理 依赖文件 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> </parent> <dependencies> <!-- SpringBoot整合Web组件 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId

springfox(swagger2) does not work with GsonHttpMessageConverterConfig

眉间皱痕 提交于 2019-12-18 01:21:23
问题 What I am trying to build is a spring-boot (v1.2.3) application and expose my Rest API with SpringFox(swagger2) v2.0.0 my Swagger Spring config @EnableSwagger2 @Configuration public class SwaggerConfig { @Bean public Docket myApi() { return new Docket(DocumentationType.SWAGGER_2) .genericModelSubstitutes(DeferredResult.class) .useDefaultResponseMessages(false) .forCodeGeneration(false) .pathMapping("/my-prj"); } } I need to use gson to convert my pojo's to json, and I do it this way:

swagger @ApiModelProperty example value for List<String> property

≯℡__Kan透↙ 提交于 2019-12-17 22:45:30
问题 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"

Swagger: variant schema shape dependant on field value

前提是你 提交于 2019-12-17 21:19:27
问题 I have a model defined as: Event: type: object properties: id: type: string timestamp: type: string format: date-time type: type: string enum: - click - open - sent click: type: object properties: url: type: string title: type: string open: type: object properties: subject: type: string sent: type: object properties: subject: type: string from: type: string to: type: string However, the shape is actually different depending on the value of the type enum field. It can be one of three, I tried

Swagger 2.0: Multiple Path objects with different paths but same request and response

让人想犯罪 __ 提交于 2019-12-17 20:49:00
问题 Due to some backward compatibility reasons, I need to support both the paths /ab and /a-b . The request and response objects are going to be the same for both of the paths. Can I have something like the following in my Swagger spec so that I do not have to repeat the request and response object definitions for both the paths. paths: /ab: /a-b: post: ... 回答1: Yes, you can have a path item reference another path item, like this: paths: /ab: ... /a-b: $ref: '#/paths/~1ab' Here, ~1ab is an

Swagger: “equivalent path already exists” despite different parameters

☆樱花仙子☆ 提交于 2019-12-17 20:46:18
问题 I'm trying to turn the Atom Publishing Protocol (RFC5023) in to a Swagger / OpenAPI spec to exercise writing those specs. I ran into the following problem: in Atom there are different types of URIs, e.g. Collection and Member URIs. My idea was to document it like this: paths: /{CollectionURI}: get: summary: List Collection Members ... post: summary: Create a Resource ... parameters: - $ref: "#/parameters/CollectionURI" /{MemberURI}: get: summary: Retrieve a Resource ... parameters: - $ref: "#

Use object type query param in swagger documentation

不问归期 提交于 2019-12-17 20:45:51
问题 I have a GET route where I would like to encode an object parameter in the url as a query string. When writing the swagger documentation I basically get errors that disallow me to use schema / object types in a query type parameter: paths: /mypath/: get: parameters - in: path name: someParam description: some param that works required: true type: string format: timeuuid #good param, works well - $ref: "#/parameters/mySortingParam" #this yields an error parameters: mySortingParam name: paging