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
34
votes
8 answers

Converting a Swagger YAML file to JSON from the command line

I'd like to convert a Swagger YAML file to JSON from the command line. The plan is to use this command line during a CI job. I've searched on google and found many solutions, but most of them use Python or Ruby, which I'd prefer not to use. For…
mkrufky
  • 3,268
  • 2
  • 17
  • 37
34
votes
7 answers

Swagger UI - How can I expand all the operations by default?

All the operations appear collapsed when I open it and I want it to be expanded by default. Is there any property I need to change to achieve it? This is my swagger Bean: @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean …
Gerardo Martínez
  • 793
  • 2
  • 12
  • 26
34
votes
3 answers

Swagger - Springfox always generates some response messages (401,403...) by default. How can I remove them?

I have controller as simple as this: @RequestMapping(value="/async/data", method=RequestMethod.GET, produces="application/json") @ApiOperation(value = "Gets data", notes="Gets data asynchronously") @ApiResponses(value={@ApiResponse(code=200,…
codependent
  • 23,193
  • 31
  • 166
  • 308
33
votes
5 answers

Use java.time.Instant to represent DateTime instead of OffsetDateTime

I'm using the openApi maven plugin to generate java request/responses for a REST api. The request has a DateTime property, when I run the generator I get the DateTime property of the attribute represented as java.time.OffsetDateTime. The problem is…
sromdhane
  • 375
  • 1
  • 4
  • 7
33
votes
2 answers

Swagger Editor multiple parameters in body

So I understand that if we want body parameters we have to have a schema, which I do. The issue is no matter how I try to define my schema it does not allow me to have multiple body parameters. Here is an example of one of the methods I have tried.…
Jacob Brauchler
  • 579
  • 2
  • 7
  • 22
33
votes
13 answers

How to use Swagger as Welcome Page of IAppBuilder in WebAPI

I try to use Swagger with Microsoft WebAPI 2. For the moment, I've the following call in a method. appBuilder .ConfigureOAuth() .UseWebApi(configuration) .UseWelcomePage(); If I want to use Swagger, I must use this url…
Philippe Matray
  • 1,511
  • 1
  • 13
  • 22
32
votes
1 answer

How to fix java.lang.RuntimeException: missing swagger input or config?

I'm trying to generate java code from swagger.json using swagger-codegen-cli.jar but I get this exception: Exception in thread "main" java.lang.RuntimeException: missing swagger input or config! at…
Amine
  • 901
  • 2
  • 14
  • 33
32
votes
3 answers

Unable to resolve service for type 'Swashbuckle.AspNetCore.Swagger.ISwaggerProvider'

I am starting a new Core Web API, and would like to add Swagger to my application. My current environment: .Net Core 3.0 Swashbuckle.AspNetCore 5.0.0-rc4 Here is my Startup.cs class and configuration: public void…
32
votes
1 answer

enum of objects in swagger UI?

I have an enum of other definitions in my Swagger spec: "action": { "title": "Action", "description": "Action to apply to matching requests", "type": "object", "enum": [ {"delayAction": {"$ref": "#/definitions/delayAction"}}, …
davetropeano
  • 537
  • 1
  • 6
  • 8
32
votes
1 answer

Swagger schema properties ignored when using $ref - why?

I'm trying to build a Swagger model for a time interval, using a simple string to store the time (I know that there is also datetime): definitions: Time: type: string description: Time in 24 hour format "hh:mm". TimeInterval: type:…
mvc
  • 653
  • 1
  • 5
  • 9
32
votes
6 answers

How to generate java client code for swagger REST API documentation

My scenario is the following. I have a swagger .json eg.: http://petstore.swagger.io/v2/swagger.json I want to use a generated java client for the REST API above, like: PetApi petApi = new PetApi(); Pet pet = new…
csikos.balint
  • 1,107
  • 2
  • 10
  • 25
32
votes
2 answers

How to specify that a pdf is returned in swagger?

I have a get call in my swagger REST API that needs to return a pdf file. There is no clear example / documentation on how to do this without causing a syntax error. responses: 200: description: Returns PDF schema:…
Scottingham
  • 906
  • 2
  • 11
  • 26
31
votes
2 answers

How to generate OpenAPI 3.0 YAML file from existing Spring REST API?

I have an existing Spring REST API for which I want to generate the OpenAPI 3.0 YAML file and not Swagger 2.0 JSON/YAML? Since as of now, SpringFox does not support YAML generation. It generates JSON with Swagger 2.0 (which follows OPEN API 3.0…
Dev Utkarsh
  • 1,377
  • 2
  • 18
  • 43
31
votes
8 answers

Swagger UI passing authentication token to API call in header

I am new to Swagger. I am using Swagger UI to generate swagger documentation. I have two API calls. First call is to generate token based on user name and password. Second call needs token generated by first call. How I set that token for second…
Java P
  • 2,241
  • 6
  • 31
  • 45
31
votes
1 answer

How can I describe complex json model in swagger

I'm trying to use Swagger to describe web-api I'm building. The problem is that I can't understand how to describe complex json object? For example, how to describe this objects: { name: "Jhon", address: [ { type: "home", line1:…
Ido Ran
  • 10,584
  • 17
  • 80
  • 143