EasySwagger

Easy Swagger for Spring Boot

Лицензия

Лицензия

Категории

Категории

Swagger Межпрограммное взаимодействие REST Frameworks
Группа

Группа

io.github.iamyours
Идентификатор

Идентификатор

easyswagger
Последняя версия

Последняя версия

0.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

EasySwagger
Easy Swagger for Spring Boot
Система контроля версий

Система контроля версий

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

Скачать easyswagger

Как подключить последнюю версию

<!-- 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"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
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

Модули Проекта

Данный проект не имеет модулей.

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
}

Версии библиотеки

Версия
0.0.2