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
21
votes
2 answers

How to use Swagger @ApiResponses annotation in Kotlin?

How to convert the following Swagger annotations from Java to Kotlin? @ApiResponses(value = { @ApiResponse(code = 200, message = "Given admin user found"), @ApiResponse(code = 404, message = "..."), @ApiResponse(code = 500,…
Frido
  • 382
  • 5
  • 14
21
votes
2 answers

Swagger: wildcard path parameters

I have an API which allows any arbitrary path to be passed in, for example all of these: /api/tags /api/tags/foo /api/tags/foo/bar/baz Are valid paths. I tried to describe it as follows: /tags{tag_path}: get: parameters: - name:…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
21
votes
5 answers

What is causing the error that swagger is already in the route collection for Web API 2?

I installed Swagger in my ASP.Net MVC Core project and it is documenting my API beautifully. My co-worker asked me to install it in a full framework 4.6.1 project so I've done the following. In Package Console Manager run: Install-Package…
Sam
  • 4,766
  • 11
  • 50
  • 76
21
votes
5 answers

How to show XML comments of class properties in Swagger (MVC 6 Web API JsonResult)

I've added XML comments to my class members but Swagger won't show them in the UI. Am I doing something wrong? UPDATE: It looks like you can't document your model classes in Swashbuckle (5.5.3) with @ApiModel and @ApiModelProperty annotations…
user405723
  • 481
  • 3
  • 7
  • 21
21
votes
5 answers

Swagger + Spring security - Hide methods based on roles

I have an API that has different consumers. I'd like them to get relevant documentation based on their roles in Spring Security. E.g API operation A is constricted to Role A and Role B API operation B is constricted to Role B API operation C is open…
Espen Schulstad
  • 2,355
  • 3
  • 21
  • 32
21
votes
4 answers

How to define different query parameters for same path in OpenAPI (Swagger)?

I am starting a REST service, using Swagger Codegen. I need to have different responses for different parameters. Example: /path can use ?filter1= or ?filter2=, and these parameters should produce different response messages. I want my…
Anil Pediredla
  • 704
  • 2
  • 8
  • 20
21
votes
3 answers

Defining enum for array in Swagger 2.0

type": "array", "items": { "type": "string", "enum": ["MALE","FEMALE","WORKER"] } or type": "array", "items": { "type": "string", }, "enum": ["MALE","FEMALE","WORKER"] ? Nothing in the spec about this. The goal is of course to get…
Esko Piirainen
  • 1,296
  • 2
  • 14
  • 28
21
votes
3 answers

How to describe WebSocket interface?

For restful services Swagger is a standardized way to describe the interface. Is there already a way to describe Websocket interfaces?
JohnDoe
  • 2,422
  • 5
  • 29
  • 44
21
votes
1 answer

How can I make url path in Swashbuckle/Swaggerwork when api is served from inside another project?

all. I am trying to document a WebApi 2 using Swashbuckle package. All works great if the API is running by itself i.e. localhost/api/swagger brings me to ui and localhost/api/swagger/docs/v1 to json. However the producation app initializes this…
Dmitriy
  • 638
  • 1
  • 6
  • 12
21
votes
3 answers

How to define empty array in swagger

I know how to make array of string data in swagger like this: "photoUrls" : { "type":"array", "items":{ "type":"string" } } It will show output like this: "photoUrls":[ "string" ] How to make output like…
smftr
  • 923
  • 3
  • 17
  • 31
21
votes
3 answers

How to get Swagger to send API key as a http instead of in the URL

I am using swagger with servicestack but I am getting a 401 unauthorised error from my /resources URL becuase it requires an API key. Unless I'm mistaken, according to the documentation I should set supportHeaderParams to true as well as the…
Rob Bird
  • 3,764
  • 2
  • 28
  • 38
21
votes
2 answers

Swagger HashMap property type

Is there any way to define a HashMap or Generic Object type in the models section? I have a REST service that returns products and those products can have different options. The options property are basically a HashMap, where the id is the option…
jplaza
  • 256
  • 1
  • 3
  • 5
20
votes
3 answers

Generating POJOs using OpenAPI generator with Lombok Annotations

I am using OpenAPI generator maven plugin like one below for generating Java client code for models . org.openapitools openapi-generator-maven-plugin 4.3.1
Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39
20
votes
2 answers

how to indicate that a parameter is conditionally required when another parameter is used in Swagger Open API 3.0

I have created a RESTful API, and I am now defining the Open API 3.0 JSON representation for the usage of this API. I am requiring usage of a parameter conditionally, when another parameter is present. So I can't really use either required: true or…
JohnRDOrazio
  • 1,358
  • 2
  • 15
  • 28
20
votes
6 answers

How to validate openapi 3.0.0 yaml spec?

I have a yaml specification that has been updated from swagger 2.0 to openapi 3.0.0 The file itself is about 7,000 lines so it is challenging to validate by hand. I need to figure out which tags I have are no longer compatible with openapi 3.0.0.…
William Ross
  • 3,568
  • 7
  • 42
  • 73