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
20
votes
3 answers

"Type 'string | string[]' is not assignable to type 'string'

I am using node + typescript and integrated swagger for API Calls. I have a following request in swagger http://localhost:3033/employees/search/?username=test Here I want to find the records having username = test. So I parse the query string…
Oops
  • 1,373
  • 3
  • 16
  • 46
20
votes
6 answers

How to develop a simple REST Client using Swagger codegen?

I'm learning about Swagger and how to generate REST Client using Swagger codegen. I know how to do documentation with Swagger, also I know how to generate a simple REST Server with Swagger, but I don't know how to generate a simple REST Client with…
elvis
  • 956
  • 9
  • 33
  • 56
20
votes
5 answers

Add `host`, `basePath` and `schemes` to swagger.json using Swashbuckle Aspnetcore

I am using official doc step by step method to configure Swagger UI and generate Swagger JSON file in my ASP.NET core API application. Get started with Swashbuckle and ASP.NET Core If I look at my generated swagger.json file - it is missing three…
Jsinh
  • 2,539
  • 1
  • 19
  • 35
20
votes
2 answers

How to declare a $ref property as readOnly in OpenAPI (Swagger)?

I am trying to add a read-only field for 'House' in this example. The house is another model that I want to be read-only. In this example, the array of Dogs can be set to readOnly without an error, but when I set the single definition of House to…
Mark Hayward
  • 424
  • 1
  • 5
  • 9
20
votes
1 answer

How to DRY when using Swagger UI and the ApiResponses annotations with Java Spring endpoints?

I like Swagger because it makes your apis very user friendly. I use Swagger annotations like @ApiParam @ApiResponse | @ApiResponses @ApiOperation Others On endpoints, query params, request params, request body and so on. I like to keep my…
Raf
  • 7,505
  • 1
  • 42
  • 59
20
votes
4 answers

How to define events in OpenAPI / Swagger spec?

How can an event-driven microservices architecture be defined using the OpenAPI / Swagger specification? For events, it is important to document the event payload passed among different services, even when they are not accessed via HTTP…
Hammer
  • 8,538
  • 12
  • 44
  • 75
20
votes
4 answers

Update postman collection from swagger specification file

I'm importing a swagger specification file into postman to create a collection, at this point, works as expected and the collection is generated with all requests & sub-folders, fine!!. But when the api is updated, I need update the postman to…
rafrsr
  • 1,940
  • 3
  • 15
  • 31
20
votes
3 answers

How to set base path property in swagger for .Net Core Web API

i've built a Web API in ASP.Net Core (version 1.1.2) and i use the Swashbuckle.AspNetCore for generating the swagger definition. below is a part of the automatically generated swagger definition. i would like to change the paths so it does not…
GeertvdC
  • 2,758
  • 1
  • 22
  • 26
20
votes
3 answers

Is it possible to have NSwag ignore a controller?

I used NSwag to generate a client for a single controller; I needed it as its own separate client. I would like for it to be ignored when the Swagger specification is generated in the future. I tried adding this attribute at the top of the…
James B. Nall
  • 1,398
  • 3
  • 16
  • 27
20
votes
3 answers

Location of swagger.json when created with Swashbuckle

When I build and run my Azure Web API I get a nice swaggerUI. I want to add the API to Azure API Management. For this I need either a URL or the swagger.json file. Where does Swashbuckle put the file? Or if it generates it on the fly, how can I get…
Richard210363
  • 8,342
  • 6
  • 37
  • 63
20
votes
3 answers

Convert JSON to JSON Schema draft 4 compatible with Swagger 2.0

I've been given some JSON files generated by a REST API with plenty of properties. I've created a Swagger 2.0 definition for this API and need to give it the corresponding schema for the response. The main problem: this JSON file has loads of…
Cwellan
  • 305
  • 1
  • 3
  • 12
20
votes
2 answers

Swagger send body and formData parameter

I'm using Swagger 2.0 and I have a problem to send multiple post parameters. I have a swagger error Operation cannot have a body parameter and a formData parameter and I don't know how to fix it. In my definition I have a body parameter and this…
John
  • 4,711
  • 9
  • 51
  • 101
20
votes
3 answers

How should I use Swagger with Hapi?

I have a working ordinary Hapi application that I'm planning to migrate to Swagger. I installed swagger-node using the official instructions, and chose Hapi when executing 'swagger project create'. However, I'm now confused because there seem to be…
Kitanotori
  • 1,741
  • 5
  • 16
  • 23
20
votes
2 answers

swagger date field vs date-time field

I am using swagger to test my rest api, one of the property of my entity class is a date field for which I need the date in yyyy-mm-dd format , but swagger model schema is showing this field as date-time instead of date field, therefore it gives…
Sourav
  • 416
  • 1
  • 5
  • 13
20
votes
2 answers

Swagger: Reusing an enum definition as query parameter

I would like to use an enum defined in definitions as part of my parameter definitions in a query string. I'm defining the Swagger Enum in the definitions part of my Swagger 2.0 spec file. OperationType: type: string enum: - registration -…
rdrey
  • 9,379
  • 4
  • 40
  • 52