EasySwagger

Easy Swagger for Spring Boot

License

License

Categories

Categories

Swagger Program Interface REST Frameworks
GroupId

GroupId

io.github.iamyours
ArtifactId

ArtifactId

easyswagger
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

EasySwagger
Easy Swagger for Spring Boot
Source Code Management

Source Code Management

https://github.com/iamyours/EasySwagger.git

Download easyswagger

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.iamyours/easyswagger/ -->
<dependency>
    <groupId>io.github.iamyours</groupId>
    <artifactId>easyswagger</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.iamyours/easyswagger/
implementation 'io.github.iamyours:easyswagger:0.0.2'
// https://jarcasting.com/artifacts/io.github.iamyours/easyswagger/
implementation ("io.github.iamyours:easyswagger:0.0.2")
'io.github.iamyours:easyswagger:jar:0.0.2'
<dependency org="io.github.iamyours" name="easyswagger" rev="0.0.2">
  <artifact name="easyswagger" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.iamyours', module='easyswagger', version='0.0.2')
)
libraryDependencies += "io.github.iamyours" % "easyswagger" % "0.0.2"
[io.github.iamyours/easyswagger "0.0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter jar 2.3.3.RELEASE
io.springfox : springfox-swagger2 jar 2.9.2
io.springfox : springfox-swagger-ui jar 2.9.2
org.springframework.boot : spring-boot-starter-web jar 2.3.3.RELEASE

Project Modules

There are no modules declared in this project.

How to use

maven

<dependency>
  <groupId>io.github.iamyours</groupId>
  <artifactId>easyswagger</artifactId>
  <version>0.0.2</version>
</dependency>
  • add @EnableEasySwagger below @EnableSwagger2
  • replace annotation with normal doc info

Example

Controller

replace annotation

@Api(tags = "学生接口")
@RestController
@RequestMapping("web/v1/student")
public class StudentController {

    @ApiOperation("根据编号获取学生信息")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "stu_no", value = "学生编号"))
    @GetMapping("getByNo")
    public StudentVO getByNO(@RequestParam("stu_no") String stuNo) {
        StudentVO stu = new StudentVO();
        stu.setStuNo(stuNo);
        stu.setName("张三");
        return stu;
    }
    
    @ApiOperation("添加学生信息")
    @ApiImplicitParams(
        {
            @ApiImplicitParam(name = "name", value = "学生名称", defaultValue = "张三"),
            @ApiImplicitParam(name = "no", value = "学生编号", defaultValue = "std-10001", required = true)
        }
    )
    @PostMapping("add")
    public StudentVO addStudent(String name, String no) {
        StudentVO s = new StudentVO();
        s.setName(name);
        s.setStuNo(no);
        return s;
    }
}

to

/**
 * 学生接口
 */
@RestController
@RequestMapping("web/v1/student")
public class StudentController {
    /**
     * 根据编号获取学生信息
     * @param stuNo 学生编号
     */
    @GetMapping("getByNo")
    public StudentVO getByNO(@RequestParam("stu_no") String stuNo) {
        StudentVO stu = new StudentVO();
        stu.setStuNo(stuNo);
        stu.setName("张三");
        return stu;
    }

    /**
     * 添加学生信息
     * @param name 学生名称|张三
     * @param no   学生编号|required|std-10001
     */
    @PostMapping("add")
    public StudentVO addStudent(String name, String no) {
        StudentVO s = new StudentVO();
        s.setName(name);
        s.setStuNo(no);
        return s;
    }
}

for model

replace

@ApiModel("学生实体")
public class StudentVO {
    @ApiModelProperty("学生姓名")
    private String name;
    @ApiModelProperty("学生编号")
    private String stuNo;

    //setter and getter
}

to

/**
 * 学生实体
 */
public class StudentVO {
    private String name;    //学生姓名
    private String stuNo;   //学生编号

    //setter and getter
}

Versions

Version
0.0.2