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
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
52
votes
5 answers

Specify an array of strings as body parameter in swagger API

I would like to post an array of strings like [ "id1", "id2" ] to a Swagger based API. In my swagger file, I have those lines: paths: /some_url: post: parameters: - name: ids in: body required: true What…
Achim
  • 15,415
  • 15
  • 80
  • 144
49
votes
3 answers

How to describe this POST JSON request body in OpenAPI (Swagger)?

I have a POST request that uses the following JSON request body. How can I describe this request body using OpenAPI (Swagger)? { "testapi":{ "testapiContext":{ "messageId":"kkkk8", "messageDateTime":"2014-08-17T14:07:30+0530" …
Anirban Sen Chowdhary
  • 8,233
  • 6
  • 39
  • 81
46
votes
6 answers

How to generate swagger.json

I am using java spring boot framework to create REST api for my project and I am using "springfox-swagger2 and springfox-swagger-ui" for generating swagger documentation. I am able to see my documentation using the URL…
Bikesh M
  • 8,163
  • 6
  • 40
  • 52
45
votes
18 answers

Why does springfox-swagger2 UI tell me "Unable to infer base url."

Why does springfox-swagger2 UI tell me Unable to infer base url. As far as I know, I am using a typical Swagger spring-boot configuration. As you can see in the screenshot, the swagger-fox url backing the UI is example.com/api . NOTE: I get a…
djangofan
  • 28,471
  • 61
  • 196
  • 289
45
votes
14 answers

Swagger UI - " TypeError: Failed to fetch" on valid response

I've just pulled down the latest Swagger from the Git repo (3.0.19) using: https://github.com/swagger-api/swagger-ui.git and updated my API to use the new version. Ran git describe --tags to confirm and my version is currently:…
Hexie
  • 3,955
  • 6
  • 32
  • 55
45
votes
3 answers

How to specify a property can be null or a reference with swagger

How to specify a property as null or a reference? discusses how to specify a property as null or a reference using jsonschema. I'm looking to do the same thing with swagger. To recap the answer to the above, with jsonschema, one could do this: { …
djpinne
  • 673
  • 1
  • 6
  • 9
41
votes
16 answers

Why HATEOAS starts creating issue for spring-boot version >= 2.2.x during startup with Swagger 2.x?

I moved my project from spring-boot 2.1.9 to 2.2.0. While starting the project, I am facing the below error messages. Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type…
VIJ
  • 1,516
  • 1
  • 18
  • 34
37
votes
7 answers

How to break swagger 2.0 JSON file into multiple modules

I'm trying to break my API document up into multiple JSON files that can be edited independently. All the examples I've been able to find use the Swagger 1.2 schema which has a "api":{} object for breaking it down. That appears to be missing from…
John P
  • 1,540
  • 2
  • 22
  • 34
36
votes
3 answers

Swagger complex response model with dynamic key value hash maps

I'm struggling with the syntax of swagger to describe a response type. What I'm trying to model is a hash map with dynamic keys and values. This is needed to allow a localization. The languages may vary, but english should always be provided. The…
user1736217
  • 425
  • 1
  • 4
  • 7
35
votes
11 answers

Springfox swagger not working in spring boot 2.2.0

I want to upgrade spring boot v2.1.9 to 2.2.0. But after the upgrade I am getting some exceptions, which says spring fox is using an older version of spring-plugin-core. Is there any alternate solution for this or do I need to give up the springfox…
Joyson Rego
  • 968
  • 2
  • 11
  • 29
35
votes
6 answers

Spring Boot & Swagger UI. Set JWT token

I have a Swagger config like this @EnableSwagger2 @Configuration public class SwaggerConfig { @Bean public Docket api() { List schemeList = new ArrayList<>(); schemeList.add(new…
isADon
  • 3,433
  • 11
  • 35
  • 49
35
votes
4 answers

How to change basePath for Springfox Swagger 2.0

I'm running a service, where Swagger UI is accessible at: http://serviceURL/swagger-ui.html However, it is behind a proxy, such as: http://proxyURL/serviceName Generated URLs by Swagger UI are looking like: http://proxyURL/ instead of the actual…
Martin Asenov
  • 1,288
  • 2
  • 20
  • 38
33
votes
1 answer

Using @RequestParam annotated method with swagger ui

I am using Springfox libraries to generate documentation for REST service and display it in Swagger UI. I followed the directions in Springfox documentation. I have one controller, which uses parameters from query string and the method is mapped as…
jny
  • 8,007
  • 3
  • 37
  • 56
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