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
22
votes
2 answers

Swagger require all properties

Given the following schema definition (which is a valid way to define required properties): MySchema: type: object required: [property1, property2, property3] properties: property1: type: integer property2: type: integer property3: …
JeB
  • 11,653
  • 10
  • 58
  • 87
22
votes
1 answer

Data annotations in Swagger

I am using ASP.NET and Swagger that exposes a complex type that accepts a POST. It has a number of string fields that have different restricted lengths. How can I reflect that in the Swagger UI?
illug
  • 793
  • 1
  • 9
  • 23
22
votes
4 answers

Swashbuckle Swagger - How to annotate content types?

How do I annotate my ASP.NET WebAPI actions so that the swagger metadata includes the content-types that my resources support? Specifically, I want the documentation to show that one of my resources can return the 'original' application/json and…
Luke Puplett
  • 42,091
  • 47
  • 181
  • 266
22
votes
3 answers

Swagger 2.0 where to declare Basic Auth Schema

How do I define basic authentication using Swagger 2.0 annotations and have it display in swagger UI. In the resource I have: @ApiOperation(value = "Return list of categories", response=Category.class, responseContainer="List", httpMethod="GET",…
mad_fox
  • 3,030
  • 5
  • 31
  • 43
22
votes
4 answers

How to send Authorization header with a request in Swagger UI?

I have a ASP.NET Web Api 2 application. I added Swashbuckle to it (Swagger for .NET). It displays my endpoints no problem, but in order to send a request I need to attach an Authorization header to that request. If I understand correctly in order to…
Marta
  • 1,132
  • 1
  • 10
  • 26
21
votes
1 answer

Maven: package io.swagger.annotations does not exist

I want to document my project with swagger. I add swagger annotations and io.springfox dependencies to my project but when I run mvn clean package I have a lot of errors: PS D:\parent-project> mvn clean package [INFO] Scanning for projects... [INFO]…
Sotnas
  • 213
  • 1
  • 2
  • 5
21
votes
2 answers

Swagger: wildcard path parameters

I have an API which allows any arbitrary path to be passed in, for example all of these: /api/tags /api/tags/foo /api/tags/foo/bar/baz Are valid paths. I tried to describe it as follows: /tags{tag_path}: get: parameters: - name:…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
21
votes
3 answers

Defining enum for array in Swagger 2.0

type": "array", "items": { "type": "string", "enum": ["MALE","FEMALE","WORKER"] } or type": "array", "items": { "type": "string", }, "enum": ["MALE","FEMALE","WORKER"] ? Nothing in the spec about this. The goal is of course to get…
Esko Piirainen
  • 1,296
  • 2
  • 14
  • 28
20
votes
7 answers

How to change swagger-ui.html default path

I wanna change my swagger-ui path from localhost:8080/swagger-ui.html to localhost:8080/myapi/swagger-ui.html in springboot redirect is helpless to me
Chen Zhang
  • 201
  • 1
  • 2
  • 3
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
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: 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
19
votes
4 answers

Spring boot Swagger implementation using Spring Fox Failed to start bean 'documentationPluginsBootstrapper'

I am using the Springfox jars for implementation of swagger in my spring boot project the gradle dependencies look like: dependencies { compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.1.3.RELEASE' compile…
vaibhav
  • 3,929
  • 8
  • 45
  • 81