使用招摇的Web API文档 [英] Web API Documentation using swagger

查看:207
本文介绍了使用招摇的Web API文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来招摇,我见过几个在线文档来实现扬鞭我的WebAPI和使用的一些SwaggerConfig的属性来定制。

I am new to swagger, I have seen couple of online documentation to implement Swagger to my webapi and used some of the properties of SwaggerConfig to customize.

下面是我的要求: -
我需要显示招摇文档只能在资源管理器的基础上API_KEY文本框应该配合我的app.config项的值按一下按钮

Here is my requirement :- I need to show swagger documentation only on "Explore" button click based on the value of "API_Key" TextBox which should match with my app.config key.

所以,我看到了实现这样的: -

So I am seeing to implement like this:-


  1. 用户来我昂首阔步主页,默认情况下它会产生空的文档,除非在图像中显示的标题。

  2. 进入API_KEY在文本框中的标题提供,然后点击浏览。

  3. 输入的API密钥进行验证,在我的app.config键或如果可能的话在SwaggerConfig。

  4. 如果验证显示文档否则显示错误信息为无效API密钥。

  1. User comes to my swagger home page, by default it will have empty documentation, except the header as shown in the image.
  2. Enters API_Key in the textbox provided in the header and click on Explore.
  3. Entered API key is validated with the key in my app.config or if possible in the SwaggerConfig.
  4. If validated show documentation else show error message as invalid API key.

需要的建议。

亲切的问候,
Raghu

Kind Regards, Raghu

推荐答案

只需编辑 index.html的并添加您需要的 addApiKeyAuthorization 更改事件的标题。查看更多在这里:

Simply edit the index.html and add the headers you need on the addApiKeyAuthorization change event. See more here:

https://github.com/swagger-api/swagger-ui#header-parameters

这篇关于使用招摇的Web API文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆