Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web API Documentation using swagger

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.

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.

enter image description here

So I am seeing to implement like this:-

  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.

Need suggestions.

Kind Regards, Raghu

like image 562
Raghurocks Avatar asked Aug 10 '26 01:08

Raghurocks


1 Answers

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

like image 99
fehguy Avatar answered Aug 12 '26 18:08

fehguy