Thomas Bembridge

Simplify your Springfox/Swagger setup with Springfox-Loader

November 22, 2016

Today I want to shine some light on Springfox-Loader, a nice little library written by a friend of mine, Jarle Hansen.

What does it do?


Simplifies the initialization of Springfox. It does not offer all the flexibility and configuration options available in Springfox, but is created to be a simple way to get spring + swagger up and running without the need for a lot of configuration.

How does it work

To get started all that is required is to add the @EnableSpringfox annotation in your spring-boot application and supplying the required title and version properties.

    @Info(title = "title", version = "${version}")

This will give you a working swagger endpoint that can be reached at localhost:8080/swagger-ui.html

This is great for getting something up real quick so that you can tests against your endpoints.

Another great feature of the library is the listValueProps endpoint that can be enabled by setting listValueProps = true.

    listValueProps = true,
    value = @Info(title = "", version = ""

This will create a listValueProps endpoint that displays all the @Value-annotations (key and default value) used in the application. The endpoint is displayed in swagger-ui as ‘Value-properties’. By default this is disabled.


To quickly show you how Springfox-Loader works i’ve made a tiny example project in java to illustrate how this works.

First i created a @RestController with a few simple @RequestMapping annotations for a /hello-world and hello endpoint.

public class HelloWorldController {

    @RequestMapping(value = "/hello-world", method = RequestMethod.GET)
    private String helloWorld() {
        return "Hello World!";

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    private String hello(@RequestParam String person) {
        return "Hello " + person;

Starting up the spring-boot application now will allow me to hit the endpoints and see this: Hello World without Springfox / Swagger

While this works and lets me test my endpoints. The approach is neither elegant nor very scalable as you continue to add on additional and even more complex endpoints.

So lets see how we can improve this by using Springfox-Loader to quickly get started with Springfox/Swagger!

As per instructions in the Springfox-Loader github we add the required dependency.

repositories {

dependencies {

Then in our class that starts up our application we add the required Springfox-Loader annotation.

    @Info(title = "Springfox-Loader-Demo", version = "1.0.0"))
public class Application {

	public static void main(String[] args) {, args);

Now once you build and run the application you can navigate to localhost:8080/swagger-ui.html

Swagger Overview

Expanding each of the listed endpoints shows you more detailed information and also allows you to run the endpoints.

Detailed View - Testing Endpoint

Here you can see all the details regarding the /hello endpoint. Its a GET, it requires a query parameter “person” and it returns a String.

I added in my name, “Thomas” and pressed the “Try it out!” button and got a “Hello Thomas” string and a 200 OK returned directly in the swagger UI.


Springfox-Loader enables you to instantly get swagger up and running and gives you some additional benefits like more readable endpoints + access to your @Value annotations.

This makes it a good choice if its your first time using swagger or you just need to get something up and running really fast.

We have actually taken the Springfox-Loader plugin and applied it to the template / starter-kit that i use in my daily work for getting new microservices up and running. So far its been working great!

Head over to Springfox-Loader on Github and give it a try.

Written by Thomas Bembridge Software Developer working at SpareBank 1 in Norway. Opinions and ideas shared through this blog are my own. Follow me on Twitter!