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
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
76
votes
11 answers

Web Api How to add a Header parameter for all API in Swagger

I searched for possible ways to add a request header parameter that would be added automatically to every method in my web-api but i couldn't find a clear one. While searching i found that the method OperationFilter() has to do something about it.
user2245758
76
votes
4 answers

How to post files in Swagger (OpenAPI)?

I am using Swagger to document my REST services. One of my services requires a CSV file to be uploaded. I added the following to the parameters section in my JSON API definition: { "name": "File", "description": "The file in zip…
CodeGuru
  • 2,722
  • 6
  • 36
  • 52
71
votes
7 answers

How to change base url of Swagger in ASP.NET core

By default when you enable swagger in ASP.NET Core project it's available on url: http://localhost:/swagger/ui I would like to use a different base url instead of /swagger/ui. How/where can i configure that? I found that for older…
Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162
70
votes
5 answers

Validating JSON against Swagger API schema

I created an API spec from some JSON files and I am trying to test if the files validate against the API spec. There are some good tools to validate against JSON Schema, but I did not have chance to find a tool to validate against specs created in…
Peter G.
  • 7,816
  • 20
  • 80
  • 154
69
votes
6 answers

InvalidOperationException: Can't use schemaId .. The same schemaId is already used for type

I receive the following error. InvalidOperationException: Can't use schemaId "$Registration" for type "$PortalService.Models.Registration". The same schemaId is already used for type "$PortalService.Models.Registration" I have tried the suggestions…
John Bowyer
  • 1,213
  • 1
  • 15
  • 26
69
votes
6 answers

How to define an optional parameter in path using swagger

There is a function in my REST web service working with GET method and it has two optional parameters. I tried to define it in Swagger but I encountered an error, Not a valid parameter definition, after I set the required as false. I found out that…
Hedeshy
  • 1,266
  • 2
  • 15
  • 24
66
votes
8 answers

Springfox 3.0.0 is not working with Spring Boot 2.6.0

Springfox 3.0.0 is not working with Spring Boot 2.6.0, after upgrading I am getting the following error org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is…
Thirumal
  • 8,280
  • 11
  • 53
  • 103
66
votes
7 answers

JWT Authentication and Swagger with .NET Core 3.0

I am developing some Web API with .NET Core 3.0 and want to integrate it with SwashBuckle.Swagger. It is working fine, but when I add JWT authentication, it does not work as I expect. To do that, I added the code below: services.AddSwaggerGen(c => …
Nick Mehrdad Babaki
  • 11,560
  • 15
  • 45
  • 70
65
votes
3 answers

How to escape colons and other special characters in a YAML string?

I have the following YAML fragment: description: | "API for bean consuming applications. Examples: painted pony, lima bean" Swagger editor interprets the colon (:) as a special character, despite the quotation marks. According to the accepted…
Gustave
  • 3,359
  • 4
  • 31
  • 64
65
votes
6 answers

Why there are no themes for swagger-ui?

I like swagger for documenting Restful APIs very much, especially "Try it out!" button, but swagger-ui interface doesn't look very cool. And I cannot believe there are no templates for such amazing open source tool (or I can't find any)? I don't…
Arūnas Smaliukas
  • 3,231
  • 6
  • 27
  • 46
64
votes
1 answer

What does 'required' in OpenAPI really mean

Given the following OpenAPI definition Person: required: - id type: object properties: id: type: string Which of the below objects are valid? Only A or A & B? A. {"id": ""} B. {"id": null} C. {} This boils down to the question…
Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
63
votes
9 answers

swagger .net core API ambiguous HTTP method for Action Error

Implementing Swashbuckle/Swagger with .net Core 2 API I am now receiving the 500 error when accessing swagger.json: NotSupportedException: Ambiguous HTTP method for action - EBisAPI.Controllers._class.HandleError (EBisAPI). Actions require an …
sammarcow
  • 2,736
  • 2
  • 28
  • 56
61
votes
6 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,724
  • 5
  • 30
  • 38
61
votes
7 answers

Can Swagger autogenerate its yaml based on existing express routes?

I inherited an existing API and I would like to document it with swagger, but I don't yet know the full scope of it. Can Swagger (or another middleware/tool) auto-magically generate the yaml (for swagger) based on the existing express routes? For…
Manatax
  • 4,083
  • 5
  • 30
  • 40