swagger

How to share Swagger documentation

寵の児 提交于 2019-12-22 07:12:55
问题 I recently started using Swagger for my documentation but there are few things that are still unclear to me. I created my YAML document and now I would like to be able to share my documentation in a .pdf or HTML/Javascript page with the rest of my team. I can't use SwaggerHub because they don't have private repositories and Swagger Editor doesn't appear to allow to share the panel on the right. Just to be clear, I would like to be able to get something like: What am I missing? 回答1: I'm biased

Swagger UI freezes after API fetch and browser crashes

僤鯓⒐⒋嵵緔 提交于 2019-12-22 06:31:32
问题 I have an ASP.NET WebAPI project where I am attempting to replace our old XmlDocumentationProvider page with Swagger UI. I am using the swashbuckle swagger for webAPI 5.3.1 nuget package. I am able to navigate to localhost/MyApp/swagger, and I can see in fiddler that it makes a call to localhost/MyApp/swagger/docs/v1 to retrieve the JSON string representing my API. The call succeeds, the JSON is about 240KB, and the JSON is valid. At this point, the chrome tab freezes for about 30 seconds

http basic auth with swashbuckle api documentation

让人想犯罪 __ 提交于 2019-12-22 05:29:08
问题 could anyone know how could i integrate basic auth with swashbuckle api's documentation? I saw that there's a basicAuth function in the swaggerconfig file: c.BasicAuth("basic").Description("Basic HTTP Authentication"); What i've done: uncommented the previous line but nothing changed! does anyone have any idea what did i miss? Thanks! 回答1: A minor improvement on @MarwaAhmad 's most excellent answer, is to check for null parameters (e.g. a simple GET or call with all params in the URL) . Also

SpringBoot集成swagger

百般思念 提交于 2019-12-22 05:05:09
什么是swagger(了解请跳过,后面有集成的详细步骤) Swagger介绍 前后端分离概念 我们要了解swagger,我们就要先从前后端分离去入手。按照现在的发展趋势,可以说前后端分离已经是业内对开发和部署方式所达成的一种共识。但是还有很多公司还是采用传统的开发风格,也就是以后端的MVC为主,前端人员只要提供一些静态的HTML页面、JS、CSS、Image等,然后大部分的后端团队担当了大量的开发工作,在这种一种开发模式下,可以说前端的开发和调试都是需要依赖于后端的web容器的支持,实际上这种开发模式根本无法做到前后端真正的分离。那到底什么是真正的前后端分离呢? 真正的前后端分离的方式如上图所示, 有什么好处呢? 后端开发团队,他们只要专注后端的控制层(Controller层)、服务层(service层)、数据访问层(dao层),整个后台会通过Restful风格的API向前端去提供数据或者讲前端会通过Restful风格的API到后端获取数据。 前端开发团队,他们只要专注于前端的控制层、视图层。即除了负责前端的静态页面,还需要负责页面上所有的交互代码以及与后端API的交互工作,它要对API进行相应的调用,并获取到数据,拿到数据后对数据进行相应地处理,将数据在视图层进行相应的展示。最终在前后端分离的模式下,前端可以实现在没有后端API的情况下,还能完美地运行和完美地奔跑。

How to specify alternative response formats with swagger/OpenAPI?

邮差的信 提交于 2019-12-22 04:49:38
问题 I have a swagger.yaml something like this: swagger: "2.0" paths: /something: get: parameters: - name: format in: query type: string pattern: '^(csv|json|xml)$' responses: 200: schema: type: ? And I want to return different formats (csv, json, xml) depending on the value of the format query parameter (eg. localhost/api/something?format=csv). How can I specify the different response formats in the spec? 回答1: I found a workaround, by providing different endpoints: swagger: "2.0" paths:

Swagger - Adding multiple security parameters to the same schema definition

时光总嘲笑我的痴心妄想 提交于 2019-12-22 04:18:09
问题 Aim To include multiple security headers to every request made within the API Problem I am trying to add multiple headers to my Swagger YAML security definitions. I have trawled though the API but not have alot of luck But am finding that when making the 'Try-This-Operation' I am required to select one. Rather than able to use both. Is this correct or am I doing something incorrectly? Snippet securityDefinitions: userEmail: type: apiKey name: User Email in: header clientId: type: apiKey name:

Web Api - Swagger documentation error 500

给你一囗甜甜゛ 提交于 2019-12-22 04:13:05
问题 When I access to the swagger url: http://localhost:28483/swagger/ui/index , it generates this error: 500 : undefined http://localhost:28483/swagger/docs/v1 Any ideas? UPDATED: See this detail error in firebug: Not supported by Swagger 2.0: Multiple operations with path 'api/BimModel' and method 'GET'. See the config setting - \"ResolveConflictingActions\" for a potential workaround 回答1: Swagger might be considering two actions as one operation (like in the case of this common scenario)... GET

Web API Swagger documentation export to PDF

淺唱寂寞╮ 提交于 2019-12-22 03:58:53
问题 In according to the documentation (http://swagger.io/open-source-integrations/) there are plugins for Java to Export Swagger documentation to PDF , I just have a look the documentation but I can't see anything regarding .NET . My question is: is there something similar to the Java Plugin swagger2markup, swagger2markup-gradle-plugin in .NET or another way to export the PDF Documentation from WEB API? thanks 来源: https://stackoverflow.com/questions/40258287/web-api-swagger-documentation-export

Swagger常用的几个注解

走远了吗. 提交于 2019-12-22 03:35:45
实习期间,做一些练手项目,前后端分离以后测试成了问题,刚好接触到这一款工具,完美的解决了前后端分离以后后端开发测试,刚好最近经常使用,于是整理了一些常见的注解。 Swagger几种常见注解的了解: @Api: 作用在类上,用来标注该类具体实现内容。表示标识这个类是swagger的资源 。 参数: 1.description:描述这个类的作用。 2.tags:设置这个类的一个标签。 @ApiOperation: 用于发送一个请求,value可以加以说明 @ApiImplicitParam: 作用于参数:用于对参数进行操作 里面含有的属性包括以下几种: name :参数名。(注意这个名字要与实际方法中的参数名一致,不然会导致swagger界面出现多个参数) value : 参数的具体意义,作用。 required : 参数是否必填。 dataType :参数的数据类型。 paramType :查询参数类型,这里有几种形式: 类型 作用 path 以地址的形式提交数据 query 直接跟参数完成自动映射赋值 body 以流的形式提交 仅支持POST header 参数在request headers 里边提交 form 以form表单的形式提交 仅支持POST 注意如果想要传入一个对象类型的参数,不使用@ApiImplicitParam,然后在方法参数加上注解

Swagger (Swashbuckle) hide header

落花浮王杯 提交于 2019-12-22 01:28:18
问题 I use Swashbuckle to add Swagger documentation to my ASP.NET Web API project. How can I hide default header (with swagger logo) from documentation page without injecting CSS? 回答1: Unfortunately I think you can do it olny by javascript right now. In your SwaggerConfig.cs you can inject a .js file like this: .EnableSwaggerUi(c => { c.InjectJavaScript(thisAssembly, "yournamespace.yourscript.js"); }); So in this script you can do whatever you want, like hide the header: document.querySelector("