Questions tagged [swagger-2.0]

Swagger is a specification and framework implementation for describing, producing, consuming, and visualizing RESTful web services. Swagger 2.0 is the current generation of the spec and includes many improvements over 1.X. This specification is now known as Open API 2.0.

Read more about Swagger 2.0 here.

Learn about how to migrate from 1.x to 2.0 here.

1666 questions
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
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
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
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
99
votes
2 answers

Swagger/OpenAPI - use $ref to pass a reusable defined parameter

Let's say I've got a parameter like limit. This one gets used all over the place and it's a pain to have to change it everywhere if I need to update it: parameters: - name: limit in: query description: Limits the number of returned…
brandonscript
  • 68,675
  • 32
  • 163
  • 220
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
81
votes
2 answers

How to format Swagger 2.0 text descriptions?

I would like to format my Swagger API descriptions so that they are not simple paragraphs of text. Preferably, I'd like to add a small table to it. I did not find an online reference about text formatting in Swagger descriptions. If I launch the…
TERACytE
  • 7,553
  • 13
  • 75
  • 111
80
votes
2 answers

How to annotate a field as deprecated in OpenAPI (Swagger) 2.0?

I have the following schema definition: swagger: '2.0' ... definitions: Service: type: object properties: serviceId: type: string description: Device or service identification number example: 1111111111 …
saeedj
  • 2,179
  • 9
  • 25
  • 38
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
78
votes
7 answers

Api annotation's description is deprecated

In Swagger, the @Api annotation's description element is deprecated. Deprecated. Not used in 1.5.X, kept for legacy support. Is there a newer way of providing the description?
Soumitri Pattnaik
  • 3,246
  • 4
  • 24
  • 42
78
votes
2 answers

Swagger; specify two responses with same code based on optional parameter

This question is not a duplicate of (Swagger - Specify Optional Object Property or Multiple Responses) because that OP was trying to return a 200 or a 400. I have a GET with an optional parameter; e.g., GET /endpoint?selector=foo. I want to return…
Tommy
  • 12,588
  • 14
  • 59
  • 110
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
65
votes
9 answers

Remove Basic Error Controller In SpringFox SwaggerUI

Is there a way i can remove the "basic-error-controller" from springfox swagger-ui? Picture:
Rajkishan Swami
  • 3,569
  • 10
  • 48
  • 68
62
votes
2 answers

Migrating from Springfox Swagger 2 to Springdoc Open API

I try to follow these: https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/ How do I deal with annotations like: @ApiModel(value = "Response container") @ApiModelProperty(value = "Iventory response",…
Kalpesh Soni
  • 6,879
  • 2
  • 56
  • 59
1
2 3
99 100