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.

1516 questions
131
votes
6 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
  • 1,668
  • 2
  • 11
  • 11
103
votes
11 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,053
  • 2
  • 7
  • 12
87
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
  • 57,554
  • 29
  • 142
  • 204
83
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,192
  • 1
  • 8
  • 13
73
votes
10 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
  • 2,759
  • 2
  • 17
  • 29
65
votes
5 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
  • 2,592
  • 4
  • 21
  • 38
64
votes
16 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,115
  • 1
  • 11
  • 15
56
votes
1 answer

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
  • 6,693
  • 11
  • 69
  • 106
56
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: https://petstore.swagger.io/#!/pet/addPet has an enum option for the status property. How…
eloleon
  • 904
  • 2
  • 8
  • 18
49
votes
10 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
  • 19,599
  • 35
  • 160
  • 321
47
votes
8 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
  • 2,882
  • 7
  • 41
  • 57
44
votes
2 answers

How to describe this POST JSON request body in OpenAPI (Swagger)?

I have a POST request that uses the following JSON request body. How can I describe this request body using OpenAPI (Swagger)? { "testapi":{ "testapiContext":{ "messageId":"kkkk8", "messageDateTime":"2014-08-17T14:07:30+0530" …
Anirban Sen Chowdhary
  • 7,918
  • 4
  • 34
  • 76
40
votes
3 answers

Swagger Editor shows the "Schema error: should NOT have additional properties" error for a path parameter

I'm using http://editor.swagger.io to design an API and I get an error which I don't know how to address: Schema error at paths['/employees/{employeeId}/roles'].get.parameters[0] should NOT have additional properties additionalProperty: type,…
Emanuel Ey
  • 2,288
  • 4
  • 26
  • 37
40
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
  • 9,677
  • 9
  • 51
  • 79
37
votes
6 answers

How to generate swagger.json

I am using java spring boot framework to create REST api for my project and I am using "springfox-swagger2 and springfox-swagger-ui" for generating swagger documentation. I am able to see my documentation using the URL…
Bikesh M
  • 6,863
  • 4
  • 35
  • 49
1
2 3
99 100