Swagger module is module to generate Open API Spec and also provide Swagger UI.
<dependency>
<groupId>com.blibli.oss</groupId>
<artifactId>blibli-backend-framework-swagger</artifactId>
</dependency>
This module will automatically generate open api spec and swagger ui. This module will read all Controller class and automatically generate open api spec.
// Open API Spec
GET /v3/api-docs
// Swagger UI
GET /swagger-ui.html
By default swagger will transform all parameter on controller to become body or query param.
If we need to ignore it, we can use annotation @SwaggerIgnore
.
@RestController
public class CustomerController {
@GetMapping("/customers/{customerId}")
public Mono<Response<Customer>> get(@SwaggerIgnored MandatoryParameter mandatoryParameter,
@PathVariable("customerId") String customerId){
...
}
}
Of if we want to create custom ignored logic, we can create bean of class SwaggerIgnoredParameter
@Component
public class MandatoryParameterSwaggerIgnoredParameter implements SwaggerIgnoredParameter {
@Override
public boolean isIgnored(Parameter parameter) {
// this logic will ignored all MandatoryParameter parameters
return MandatoryParameter.class.isAssignableFrom(parameter.getType());
}
}
We can configure swagger information on Open API Spec
blibli.backend.swagger.title[email protected]@
blibli.backend.swagger.version[email protected]@
blibli.backend.swagger.description[email protected]@
blibli.backend.swagger.terms-of-service=https://www.blibli.com/