spring boot2 integrated api documentation tool swagger UI


Step 1: create a project

Step 2: import development tools

  • Open the download directory and extract the project file

  • Launch idea and import project file

Step 3: introduce swagger UI package


Step 4: create a swagger configuration

public class SwaggerConfig {

    public Docket api(){

        return new Docket(DocumentationType.SWAGGER_2)

    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("api Interface specification")


Step 5: create a POST api interface

@Api(value = "User interface", tags={"User operation interface"})
public class IndexController {

    @ApiOperation(value = "User login",notes = "Sign in",httpMethod = "POST")
    public Object get(@RequestParam @ApiParam(name="username",value="Login account",required=true) String username, @RequestParam @ApiParam(name="password",value="Password",required=true) String password){

        Map map = new HashMap();
        return map;
  • Page rendering

  • Test api interface request

  • The result returned here is the same as we expected.


Tags: Programming Spring

Posted on Sun, 12 Jan 2020 07:11:43 -0800 by codersrini