swagger 注释方式编写接口文档

介绍html

  swagger用注解的方式生成接口文档,减小工做量spring

使用spring-boot

  首先须要引入jarui

  

 <!-- 引入swagger2 -->
        <dependency>
            <groupId>com.spring4all</groupId>
            <artifactId>swagger-spring-boot-starter</artifactId>
            <version>1.8.0.RELEASE</version>
        </dependency>

  

  而后在controller中引入注解spa

  

@Api(value ="/login" ,tags={"登陆注册"})

  在方法上也引入注解code

  

    

 @ApiOperation("用户登陆")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tel",value="手机号",required = true),
            @ApiImplicitParam(name = "password",value="密码",required = true)
    })

 

效果htm

  经过访问本地 http://localhost:9004/swagger-ui.html#/ 既能够看到生成的接口文档的效果blog

 

  

相关文章
相关标签/搜索