Questions tagged [swagger]

Swagger is a framework implementation for describing, producing, consuming, and visualizing RESTful web services, based on the OpenAPI specification

Swagger is a specification and framework implementation for describing, producing, consuming and visualizing RESTful web services. It is a unique way to document your RESTful APIs on the go, as and when you code them.

The main advantage of Swagger is its flexibility - it can produce static and dynamic REST API documentation. There is even the possibility to interact with the webservice and send example queries.

It's developed by SmartBear.

On Nov 5th, 2015, the Open API Initiative extended Swagger as an OpenAPI specification to advance connected application development through open standards. Please refer to the announcement for more information.

Useful links

Frequently Asked Questions

People often ask about the following Swagger topics:

Related tags

11997 questions
269
votes
14 answers

How to omit methods from Swagger documentation on WebAPI using Swashbuckle

I have a C# ASP.NET WebAPI application with API documentation being automatically generated using Swashbuckle. I want to be able to omit certain methods from the documentation but I can't seem to work out how to tell Swagger not to include them in…
paytools-steve
  • 3,580
  • 3
  • 26
  • 21
213
votes
8 answers

How to import Swagger APIs into Postman?

Recently I wrote restful APIs with SpringMvc and swagger-ui(v2). I noticed the Import function in Postman: So my question is how to create the file which Postman needed? I am not familiar with Swagger.
Demon Coldmist
  • 2,560
  • 2
  • 13
  • 21
170
votes
7 answers

How can I represent 'Authorization: Bearer ' in a Swagger Spec (swagger.json)

I am trying to convey that the authentication/security scheme requires setting a header as follows: Authorization: Bearer This is what I have based on the swagger documentation: securityDefinitions: APIKey: type: apiKey name:…
Elmer Thomas
  • 2,068
  • 2
  • 13
  • 11
161
votes
1 answer

How to define a property that can be string or null in OpenAPI (Swagger)?

I have JSON schema file where one of the properties is defined as either string or null: "type":["string", "null"] When converted to YAML (for use with OpenAPI/Swagger), it becomes: type: - 'null' - string but the Swagger Editor shows an…
Vaibhav Patil
  • 2,603
  • 4
  • 14
  • 22
139
votes
5 answers

What is the correct way to declare a date in an OpenAPI / Swagger-file?

What is the correct way to declare a date in a swagger-file object? I would think it is: startDate: type: string description: Start date example: "2017-01-01" format: date But I see a lot of declarations like these: startDate: …
Patrick Savalle
  • 4,068
  • 3
  • 22
  • 24
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
127
votes
36 answers

Swashbuckle/Swagger + ASP.Net Core: "Failed to load API definition"

I develop an ASP.NET Core 2 application and included Swagger. Everything worked fine until I introduced a method without explicitly defining the HTTP action: public class ErrorController : Controller { [Route("/error")] public IActionResult…
Ash
  • 3,283
  • 6
  • 16
  • 20
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
121
votes
13 answers

Converting Swagger specification JSON to HTML documentation

For some REST APIs written in PHP, I was asked to create Swagger documentation, and since I was not aware of any easy way of annotating those existing APIs and create such a documentation, I used this editor to generate some for now. I saved the…
Salil
  • 1,739
  • 2
  • 15
  • 25
112
votes
38 answers

ASP.NET Core - Swashbuckle not creating swagger.json file

I am having trouble getting the Swashbuckle.AspNetCore (1.0.0) package to generate any output. I read the swagger.json file should be written to '~/swagger/docs/v1'. However, I am not getting any output. I started with a brand new ASP.NET Core API…
John Livermore
  • 30,235
  • 44
  • 126
  • 216
111
votes
13 answers

Swagger/OpenAPI mock server

I have an API reference in a Swagger file. I want to create a very simple mock server, so that when I call e.g.: mymockurl.com/users it will return a predefined JSON (no need to connect to a database). What's the easiest way to do this? I'm not a…
rafakob
  • 3,946
  • 3
  • 26
  • 36
111
votes
3 answers

How can I generate swagger based off of existing postman collection?

I am developing a REST API. during development I have used postman (chrome extension) to use and document my API. It is a wonderful tool and I have most of my API endpoints in it. However, as we near release I would like to document this API in…
StuBob
  • 1,490
  • 2
  • 10
  • 13
108
votes
7 answers

swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B

Using Web API and using swashbuckle to generate swagger documentation, I defined two different classes with the same name in two different namespaces. when I open swagger page in my browser it says Conflicting schemaIds: Duplicate schemaIds…
Mahdi Ataollahi
  • 4,544
  • 4
  • 30
  • 38
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
1
2 3
99 100