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

How to make a field in a definition required for some operations and not others

I'm writing my swagger definition in yaml. Say I have a definition that looks something like this. paths: /payloads: post: summary: create a payload ... parameters: - in: body name: payload description:…
Joseph Downing
  • 1,099
  • 2
  • 12
  • 25
26
votes
5 answers

Using Swashbuckle for Asp.net core how can I add a model to the generated model list?

I'm using Swashbuckle with ASP.net core. It is producing a nice website with a list of models at the bottom. How can I add a model to this list that isn't already appearing? I return an abstract class in one of my requests and I want to list all…
chris31389
  • 8,414
  • 7
  • 55
  • 66
26
votes
2 answers

How to return an array of objects in SwaggerHub?

I am defining an API specification in SwaggerHub using OpenAPI 2.0. The /contacts request returns an array of contacts. The definition is below: /contacts: get: tags: - contacts summary: Get all the contacts …
Krishna Adhikari
  • 357
  • 1
  • 4
  • 9
26
votes
2 answers

"discriminator" in polymorphism, OpenAPI 2.0 (Swagger 2.0)

Referencing OpenAPI 2.0, Schema Object, or Swagger 2.0, Schema Object, and the definition of discriminator field as: Adds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema…
Musa Haidari
  • 2,109
  • 5
  • 30
  • 53
26
votes
7 answers

Avoiding default basic-error-controller from swagger api

I'm using swagger2 in my spring boot project. It's working well, but I need to exclude the basic-error-controller from the api. Currently I'm using the following code using regex. It's working but is there any perfect way to do this. CODE…
Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188
26
votes
5 answers

Swagger ApiModelProperty access

I'm using the same Object both for my Request and Response on a REST endpoint. Is it possible to annotate a property with ApiModelProperty(access = "response") and then annotate the rest endpoint method with @ApiImplicitParam(access = "response") so…
hello_world_infinity
  • 4,760
  • 9
  • 32
  • 32
25
votes
1 answer

Is it possible to be in try-it-out mode by default in Swagger 2?

I am using Swagger 2 with Springfox. When you click on an endpoint, is there any way to have the Try-it-out mode activated by default, without having to click this button:
Thomas
  • 1,491
  • 13
  • 23
25
votes
1 answer

Multi-level (nested) tagging in Swagger UI

I just started working on Swagger 2.0 API recently. I am looking for some ways to organize the API documentation. Currently I'm using the @Api(tags = {"Heading1"}) Java annotation to tag each API. The generated documentation looks…
kani mozhi
  • 251
  • 1
  • 3
  • 3
25
votes
6 answers

Unable to bring up swagger-ui from spring-boot application

I have a spring boot application that i am running using embedded tomcat server. I am partially successful in getting springfox-swagger integrated with the app. If i do a /v2/api-docs , i am able to see all the documentation of all the api's in the…
Naveen Chandra
  • 281
  • 1
  • 4
  • 5
24
votes
2 answers

Swagger UI configuration with swagger-config.yaml

As per swagger documentation, Swagger-UI accepts configuration parameters in four locations. From lowest to highest precedence: The swagger-config.yaml in the project root directory, if it exists, is baked into the application configuration object…
Mahendra Kapadne
  • 426
  • 1
  • 3
  • 10
23
votes
2 answers

Replace @EnableSwagger2 after update to latest version

I migrated to latest springfox-swagger2 version 2.10.0 but looks like @EnableSwagger2 is deprecated. What annotation should I use in order to enable Swagger into Spring Boot project? @EnableSwagger2WebMvc?
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
22
votes
1 answer

How to specify examples for GET parameters in Swagger?

I'm using the online Swagger Editor to create a Swagger spec for my API. My API has a single GET request endpoint, and I'm using the following YAML code to describe the input parameters: paths: /fooBar: get: tags: - foobar …
Devdatta Tengshe
  • 4,015
  • 10
  • 46
  • 59
22
votes
3 answers

Swagger Codegen CLI Java Client - How to use it right

I'm currently playing around with my jersey2 rest service. For a better overview of the given service (description, types and so on) I make heavily use of swagger (swagger-jersey2-jaxrs). So I'm able to genereate my service description…
Matthias
  • 400
  • 1
  • 4
  • 13