swagger

How not to copy-paste 3 generic error responses in almost all paths?

天大地大妈咪最大 提交于 2019-12-19 05:36:05
问题 I want almost all my paths to have the following 3 generic error responses. How do I describe that in Swagger without copypasting these lines everywhere? 401: description: The requester is unauthorized. schema: $ref: '#/definitions/Error' 500: description: "Something went wrong. It's server's fault." schema: $ref: '#/definitions/Error' 503: description: Server is unavailable. Maybe there is maintenance? schema: $ref: '#/definitions/Error' Example of how I use this in a request: paths: /roles:

How not to copy-paste 3 generic error responses in almost all paths?

試著忘記壹切 提交于 2019-12-19 05:35:12
问题 I want almost all my paths to have the following 3 generic error responses. How do I describe that in Swagger without copypasting these lines everywhere? 401: description: The requester is unauthorized. schema: $ref: '#/definitions/Error' 500: description: "Something went wrong. It's server's fault." schema: $ref: '#/definitions/Error' 503: description: Server is unavailable. Maybe there is maintenance? schema: $ref: '#/definitions/Error' Example of how I use this in a request: paths: /roles:

Is there a way I can stop springfox swagger from scanning the model classes?

狂风中的少年 提交于 2019-12-19 03:14:55
问题 I'm currently using Springfox Swagger to document my spring boot application with a Java config. My API starts in about 75 seconds, (it was originally 20 secs without Springfox) with the whole scanning process. I currently just need the controller information without any model info. Is there a way I can exclude model scanning from the startup process in order to make my API start faster? And are there any other ways to make it faster? I'm using swagger 1.2 回答1: There is a way to prevent

Swagger Java common header

こ雲淡風輕ζ 提交于 2019-12-19 00:23:46
问题 I have a REST API server implemented with Jersey2.0 and integrated with Swagger to automate docs and client side applications. We have our own authentication header ( X-Auth-Token ) which should be applied to all requests in order to use them (Beside the login request that retrieves the token if credentials are correct). Right now I need to manually add the the token as ApiImplicitParam annotation to each of the requests in order for the generated docs to include it: @ApiImplicitParams({

k__BackingField remove in C# (seen via Swashbuckle / Swagger)

我的未来我决定 提交于 2019-12-18 19:42:33
问题 I am using Swashbuckle 5 in my ASP.NET webapi project with all default settings. It serializes my method's output in order to show me schema of the reply. I am getting documentation that looks like this: Response Class (Status 200) Model Model Schema [ { "<Key>k__BackingField": "string", "<Value>k__BackingField": "string", "<Id>k__BackingField": 0 } ] This is generated by following C# code /// <summary> /// Fetches all system configuration items /// </summary> /// <returns>List of <see cref=

k__BackingField remove in C# (seen via Swashbuckle / Swagger)

妖精的绣舞 提交于 2019-12-18 19:41:29
问题 I am using Swashbuckle 5 in my ASP.NET webapi project with all default settings. It serializes my method's output in order to show me schema of the reply. I am getting documentation that looks like this: Response Class (Status 200) Model Model Schema [ { "<Key>k__BackingField": "string", "<Value>k__BackingField": "string", "<Id>k__BackingField": 0 } ] This is generated by following C# code /// <summary> /// Fetches all system configuration items /// </summary> /// <returns>List of <see cref=

How to redirect root to swagger in Asp.Net Core 2.x?

六眼飞鱼酱① 提交于 2019-12-18 19:40:55
问题 I'm building Asp.Net Core 2.x web api integrated with Swagger. To access the swagger, I had to append /swagger to the url, eg. https://mywebapi.azurewebsites.net/swagger/ How can I redirect https://mywebapi.azurewebsites.net/ to https://mywebapi.azurewebsites.net/swagger/ ? 回答1: Install Microsoft.AspNetCore.Rewrite from Nuget In Startup.cs public void Configure(IApplicationBuilder app, IHostingEnvironment env) before app.UseMvc(); add var option = new RewriteOptions(); option.AddRedirect("^$"

Convert JSON to JSON Schema draft 4 compatible with Swagger 2.0

爷,独闯天下 提交于 2019-12-18 19:10:32
问题 I've been given some JSON files generated by a REST API with plenty of properties. I've created a Swagger 2.0 definition for this API and need to give it the corresponding schema for the response. The main problem: this JSON file has loads of properties. It would take so much time and I would make many mistakes if I write the schema manually. And it’s not the only API I need to describe. I know there are some tools to convert JSON to JSON schemas but, if I’m not mistaken, Swagger only has

springboot+mybatsi-plus+lombok+swagger-bootstra整合

南笙酒味 提交于 2019-12-18 17:53:05
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 版本要求:jdk1.8以上 框架版本介绍:springboot 2.x mybatis-plus 3.x Maven 3.x以上 辅助工具介绍:lombok 简化代码 Swagger-bootstrap-ui 生成接口文档 Yml文件 注意:1、springboot1.x与2.x版本改动较大,具体请阅看官方文档。 官方地址: https://spring.io/projects/spring-boot/ 2、mybatis-plus 3.x与2.x 版本改动较大,具体请查阅官方文档。 官网地址: https://mp.baomidou.com/ 解释说明: springboot优点在于简化配置,全家桶自动集成优秀框架,基于注解开发。 综上所有优点,我们选择了lombok,与mybatis-plus ,还有swagger-ui。这三个都是基于注解使用。我认为选择其他的感觉优点鸡肋。 pom.xml文件 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.0.RELEASE</version> <relativePath/> <!--

Swagger介绍-一套流行的API框架

人走茶凉 提交于 2019-12-18 12:31:48
简介 号称:世界最流行的API框架 官网:http://swagger.io/ 解决什么问题:在前后台分离的开发模式中,减小接口定义沟通成本,方便开发过程中 测试 ,自动生成接口文档。 实例代码位置: https://github.com/pumadong/cl-roadshow/tree/master/roadshow-swagger swagger使用方式 第一种 定义YAML文件,然后可以生成各种语言的代码框架,对于后台程序员来说,较少人会愿意写出一堆YAML格式。 第二种 swagger有各种语言的插件,可以通过配置及少量代码,生成接口文档及测试界面。 我们多做了:一次性的配置及少量注解代码。 我们不用再做:1、到Wiki中更新接口文档;2、Postman形式的测试;3、Curl形式的测试 swagger java使用介绍 对于一个SpringMVC项目,使用swagger的配置如下: pom.xml [html] view plain copy print ? <!-- Swagger --> < dependency > < groupId >io.swagger </ groupId > < artifactId >swagger-core </ artifactId > < version >1.5.8 </ version > </ dependency > <