Questions tagged [swagger-ui]

Swagger UI is a collection of HTML, CSS and JavaScript objects that dynamically generate documentation from a Swagger-compliant API

Swagger UI is part of the Swagger project.

It adds form to your APIs by making them look good and presentable so that client code can be written easily, at the same time it also makes documentation easier by integrating it with code.

It originated out of the Open API Specification. The source can be found here.

A sample Swagger UI can be found at the Pet Store.

4353 questions
242
votes
31 answers

Swagger UI Web Api documentation Present enums as strings?

Is there a way to display all enums as their string value in swagger instead of their int value? I want to be able to submit POST actions and put enums according to their string value without having to look at the enum every time. I tried…
user5326354
161
votes
7 answers

Setting up Swagger (ASP.NET Core) using the Authorization headers (Bearer)

I have a Web API (ASP.NET Core) and I am trying to adjust the swagger to make the calls from it. The calls must contains the Authorization header and I am using Bearer authentication. The calls from third party apps like Postman, etc. go fine. But I…
J.Doe
  • 1,701
  • 2
  • 10
  • 4
137
votes
15 answers

How to send custom headers with requests in Swagger UI?

I have some endpoints in the API - /user/login, /products. In Swagger UI I post email and password to /user/login and as a response I receive a token string. Then, I can copy the token from the response and want to use it as Authorization header…
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
134
votes
15 answers

How to configure Spring Security to allow Swagger URL to be accessed without authentication

My project has Spring Security. Main issue: Not able to access swagger URL at http://localhost:8080/api/v2/api-docs. It says Missing or invalid Authorization header. Screenshot of the browser window My pom.xml has the following…
shubhendu_shekhar
  • 1,373
  • 2
  • 9
  • 13
124
votes
8 answers

How to export swagger.json (or yaml)

How can I export a Swagger definition file? It should be a JSON or YAML file, e.g. swagger.json or swagger.yaml. Let's say I have an endpoint looking like http://example.com//swagger/ui/index#!: The version is api version: v1. There is no "Export"…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
111
votes
5 answers

Generate PDF from Swagger API documentation

I have used the Swagger UI to display my REST webservices and hosted it on a server. However this service of Swagger can only be accessed on a particular server. If I want to work offline, does anybody know how I can create a static PDF using the…
Aman Mohammed
  • 2,878
  • 5
  • 25
  • 39
104
votes
33 answers

Swagger not loading - Failed to load API definition: Fetch error undefined

Trying to setup swagger in conjunction with a web application hosted on IIS express. API is built using ASP Net Core. I have followed the instructions prescribed on the relevant microsoft help page regarding Swashbuckle and ASP.NET Core. Thus far I…
Jeremy S.
  • 2,841
  • 4
  • 10
  • 20
104
votes
13 answers

Swagger TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body

I have added Swagger to my Spring Boot 2 application: This is my Swagger config: @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() { // @formatter:off return new…
alexanoid
  • 24,051
  • 54
  • 210
  • 410
97
votes
4 answers

Bearer authentication in Swagger UI, when migrating to Swashbuckle.AspNetCore version 5

I'm trying to migrate from version 4.0.1 to 5.0.0-rc2 of Swashbuckle in a .NET Core 3 Preview 5 Web API project. I've got the project compiling and the Swagger UI working, but I can't get Bearer authentication to work, which I think is due to me not…
tomRedox
  • 28,092
  • 24
  • 117
  • 154
91
votes
6 answers

swagger-ui returns 500 after deployment

Out of the box configuration works perfectly on my machine, no problems at all. But when I deploy to our test environment - I get the following message 500 : { "Message": "An error has occurred." } /api/swagger/docs/v1 The deployment is to…
VisualBean
  • 4,908
  • 2
  • 28
  • 57
90
votes
19 answers

How to open local files in Swagger-UI

I'm trying to open my self generated swagger specification file my.json with swagger-ui on my local computer. So I downloaded the latest tag v2.1.8-M1 and extracted the zip. Then I went inside the sub folder dist and copied the file my.json into it.…
Adam Taras
  • 1,403
  • 1
  • 13
  • 15
80
votes
6 answers

Can't read from file issue in Swagger UI

I have incorporated swagger-ui in my application. When I try and see the swagger-ui I get the documentation of the API nicely but after some time it shows some error icon at the button. The Error message is like…
Abi P
  • 1,410
  • 3
  • 22
  • 36
80
votes
4 answers

How to define an enum in OpenAPI (Swagger)?

Does anyone know how to define possible enum values in an OpenAPI 2.0 definition so that they will be displayed in the Model tab of Swagger UI? Example here has an enum option for the status property. How to do define such an enum in OpenAPI 2.0?
eloleon
  • 1,144
  • 2
  • 10
  • 18
77
votes
7 answers

How to describe a model in Swagger for an array with simple objects?

I have a REST services to document, some of them accepts simple array like: [ { "name":"a" }, { "name":"b" }, { "name":"c" } ] How do I describe this in Swagger model section ? I can only create 'named array' like model { properties: { "arr":…
razor
  • 2,727
  • 6
  • 33
  • 45
76
votes
11 answers

Web Api How to add a Header parameter for all API in Swagger

I searched for possible ways to add a request header parameter that would be added automatically to every method in my web-api but i couldn't find a clear one. While searching i found that the method OperationFilter() has to do something about it.
user2245758
1
2 3
99 100