E. Swagger and Liquibase

Git Link

  1. Git Project
  2. Spring Batch on GIT

Definition

Swagger is an open-source software framework backed by a large ecosystem of tools that helps developers design, build, document, and consume RESTful Web services. While most users identify Swagger by the Swagger UI tool, the Swagger toolset includes support for automated documentation, code generation, and test-case generation.

Dependency on pom.xml

<properties>
   <swagger .version="">2.7.0</swagger>
</properties>

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
 <groupid>io.springfox</groupid>
 <artifactid>springfox-swagger2</artifactid>
 <version>${swagger.version}</version>
</dependency>

Swaggger config

Create Class : fr.verisure.ddo.foundation.leadbox.config.SwaggerConfig.java
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select()
.apis(RequestHandlerSelectors.basePackage("com.java.spring.controller")).paths(PathSelectors.any()).build()
.apiInfo(new ApiInfo("Spring Boot REST API.", "Spring Boot REST API.", "1.0", "Terms of service",
new Contact("Tutorial", "", "rija.ramampiandra@gmail.com"), "Java Expert Developper",
"https://www.linkedin.com/in/njarahery-ramampiandra-7893a696", new ArrayList<>()));
}
}

Add declaration on the controller :
@RestController
@RequestMapping("/")
@SwaggerDefinition(tags = { @Tag(name = "/", description = "Run Job.") })

Url access

When you run the porject you can access the WS exposed on : 
http://localhost:8080/swagger-ui.html

Liquibase context

In Liquibase you can define the application context, it's allow the developper wich script is only executed only for the context (test or dev or integration or production).
  • Context configuration for dev environment
  • For test context just change "dev" to "test" on the file application-test.properties. Then the script below is only executed for unit testing.
  • Script Liquibase executed only fro unit testing :



Comments