Simple Spring-boot Swagger Documentation
Learning Swagger documentation for rest.

To Add Swagger to your application
add the depedencies




create SwaggerConfiguration class

public class SwaggerConfig {

    public Docket productAPI(){
       return new Docket(DocumentationType.SWAGGER_2)
    private ApiInfo metaInfo(){
        return new ApiInfo(
                "Spring boot Swagger",
                "Learning Swagger For Project",
                "Tearm Of Service",
                new Contact("putracode",
                "Apache License Version 2.0",
                new ArrayList<>()




Add annotation swagger @ApiOperation
on the Method endpoint. Example

@ApiOperation(value = "Get All Data Product",
        responseContainer = "List",
        produces = "application/json",
        response = Product.class)
public Iterable<Product> getProduct(){
    return products;

@ApiModel and @ApiModelProperty
this is used for tell consumer application
about information about the property (response/ request)

@ApiModel(value = "Product Model For display and Saving Data Product")
public class Product {
    private String id;
    @ApiModelProperty(notes = "Code Product",
            required = true,
            allowEmptyValue = false,
            dataType = "String"
    private String code;
    private String name;
    private Long stock;




How to run
1. open the terminal

mvn spring-boot:run
  1. open browser




Code : Spring Boot Swagger