Add first swagger dependency:
<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>
Then create a class and add on top of the class below annotation:
@Configuration @EnableSwagger2
@Configuration
@EnableSwagger2
Now Add below Code:
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).select() .apis(RequestHandlerSelectors.basePackage("com.aamnapm.counting")) //your package name .paths(PathSelectors.any()) .build().apiInfo(apiEndPointsInfo()); } private ApiInfo apiEndPointsInfo() { return new ApiInfoBuilder().title("Spring Boot REST API") .description("Employee Management REST API") .license("Apache 2.0") .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") .version("1.0.0") .build(); }
On class controller add @Api(value = "your title") and On the Entity or DTO class add @ApiModel(value = "dto",description = "description")
@Api(value = "your title")
@ApiModel(value = "dto",description = "description")
There was an error while loading. Please reload this page.