Questions tagged [springfox]

The Springfox suite of java libraries is all about automating the generation of machine and human readable specifications for JSON APIs written using the spring family of projects.

The Springfox suite of java libraries is all about automating the generation of machine and human readable specifications for JSON APIs written using the spring family of projects. Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various compile-time java annotations.

Useful links

794 questions
18
votes
6 answers

How to customize the value of operationId generated in api spec with swagger?

I have configured my spring project using springfox 2.0. I am able to generate the open api spec with it. "paths": { "/test/testinfo": { "post": { "tags": [ "test-controller" ], "summary": "getTestInfo", …
Ganesh
  • 5,977
  • 5
  • 19
  • 25
18
votes
6 answers

How to generate offline Swagger API docs?

I have a spring boot MVC java Web app. I've been able to integrate Springfox for API documentation. I can visually see all of the APIs when server is up and running. How can I generate OFFLINE swagger API documentation? Note: I would not like to…
code
  • 5,294
  • 16
  • 62
  • 113
17
votes
3 answers

Springfox Type javax.servlet.http.HttpServletRequest not present

I'm trying to use SpringFox. Spring Boot version: 'org.springframework.boot:3.0.0-SNAPSHOT' build.gradle dependencies { ... implementation 'io.springfox:springfox-petstore:2.10.5' implementation "io.springfox:springfox-swagger2:3.0.0" …
Shadow4571
  • 382
  • 2
  • 4
  • 10
17
votes
2 answers

How do I enable CORS headers in the Swagger /v2/api-docs offered by Springfox Swagger?

I have the following file in my project: @Configuration @Order(Ordered.LOWEST_PRECEDENCE) public class SwaggerConfig { @Bean public Docket apiSwagger2Documentation() { .... } } And in the Application.java there…
Adrian Smith
  • 17,236
  • 11
  • 71
  • 93
17
votes
5 answers

Documenting Spring's login/logout API in Swagger

I am developing demo REST service using Spring Boot where user has to login in order to to perform certain subset of operations. After adding Swagger UI (using springfox library) with that simple configuration: @Bean public Docket docApi() { …
Maciej Dobrowolski
  • 11,561
  • 5
  • 45
  • 67
16
votes
10 answers

Cannot send Authorization Bearer Token using Springfox

I'm having trouble understanding why "Authorization: Bearer __" is not being sent in my api using Springfox 2.5.0. I have the following configuration: private ApiKey apiKey() { return new ApiKey( "Authorization", // name: My…
paulocdf
  • 180
  • 1
  • 1
  • 6
15
votes
3 answers

Swagger+Spring: is it possible to preserve the fields order in the payload?

Assuming my payload class is: public class Payload { private final long id; private final String aField; } springfox will sort the payload fields in the lexicographical order which will produce the following payload spec: { "aField":…
S. Pauk
  • 5,208
  • 4
  • 31
  • 41
15
votes
4 answers

SpringFox Swagger - Optional and Mandatory fields in model

I used SpringFox library for rest documentation of my spring boot app. When I click on model , all the elements are being returned as optional. Is there a way to display required elements as mandatory? Is there any additional configuration that…
Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
14
votes
2 answers

When loading the swagger-ui.html page, a request is made to host:port/ and host:port/csfr

I have a Spring boot 2 application (rest API) and use the Springfox Swagger 2 library, including the UI library. When I open the swagger interface found at http://localhost:8080/swagger-ui.html everything works as expected, but two requests are made…
user1884155
  • 3,616
  • 4
  • 55
  • 108
14
votes
2 answers

How to document additional models in Swagger for an inaccessible Controller?

I have a controller that I have to keep generic by having it accept a String as @RequestBody and return a String, i.e., String processRequest(@RequestBody String json) {...} I don't have control over the source code of that controller, but I can get…
user1902183
  • 3,203
  • 9
  • 31
  • 48
14
votes
3 answers

Filtering for API parts in swagger

I have a REST API and springfox swagger v2.6.1 included and working. But now, I would like to not always display all the controllers I have, because some of them are very technical and not intended for the average user, but I want to be able to…
totee
  • 143
  • 1
  • 1
  • 5
14
votes
2 answers

How can I manually describe an example input for a java @RequestBody Map?

I am designing an api where one of the POST methods that takes a Map of any key value pairs. @RequestMapping(value = "/start", method = RequestMethod.POST) public void startProcess( @ApiParam(examples = @Example(value = { …
Josh J
  • 6,813
  • 3
  • 25
  • 47
13
votes
4 answers

how to do friendly base url for swagger 2.8.0

I'm trying to change base access url for API documentation. The url is "http://localhost:8080/swagger-ui.html". I want to get something like "http://localhost:8080/myapi/swagger-ui.html". I use Springfox 2.8.0 Swagger, Java 8, Spring Boot 2.0 The…
Julia Tyrer
  • 131
  • 1
  • 1
  • 3
13
votes
1 answer

Adding Swagger server stubs into existing Spring application

What is the best way to plug the server stubs generated by Swagger Codegen into an existing Spring MVC application? I'm starting off by attempting to use the petstore stubs sample. My Spring configuration is in Java and looks like this: public class…
jlb
  • 19,090
  • 8
  • 34
  • 65
12
votes
6 answers

Springfox swagger-ui 3.0.0 does not bring up swagger-ui.html page

I am using springfox swagger-ui with Springboot but the fileUpload button is not enabled for multipart upload. I tried upgrading to springfox-swagger-ui 3.0.0 but that does not even bring up the swagger-ui page. Is there any way to get the file…
user1805280
  • 251
  • 1
  • 5
  • 14
1 2
3
52 53