Add swagger to a spring boot application.

  1. Add following dependency to pom.xml file.
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
package com.example.myexample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
public class MyExampleApplication {

public static void main(String[] args) {
SpringApplication.run(MyExampleApplication.class, args);
}

}
@RestController
@RequestMapping("/api")
public class StudentController{

// your code
}
  1. Add following dependency to pom.xml file.
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
@RestController
@RequestMapping("/api")
public class StudentController{

// your code
}
  1. https://stackoverflow.com/questions/62773219/suddenly-springfox-swagger-3-0-is-not-working-with-spring-webflux
  2. JavaBrains tutorial video : https://www.youtube.com/watch?v=8s9I1G4tXhA
  3. https://blog.readme.com/an-example-filled-guide-to-swagger-3-2/

--

--

--

System Administrator and Full stack web developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Exploring Twitter With Python

How to implement the bitmap on rocksdb

3 Key Points Every Developer Should Know

Remember these 3 tips to make the most out of Andrew Ng’s ML Programming Assignments

Basic Python I

Setup Asp.NET Identity DB with Entity Framework

Implementing AFL(American Fuzzy Loop)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshu Pratap

Himanshu Pratap

System Administrator and Full stack web developer.

More from Medium

Create a spring boot application that stores images

Integration Testing on Spring boot microservice with Wiremock and JUnit5

Your Domain’s Spring Boot Parent POM

Obfuscate Spring Boot Applications with Proguard Maven Plugin