swagger常用注解

@Api(常用在Controller 类上,标记为 Swagger 文档资源)

package com.yk.controller.medicine;

import com.yk.pojo.Medicine;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags={"医疗组对应接口"})
public class MediController {

    @PostMapping("/getMedicine")
    public Medicine getMedicine(){
        return new Medicine();
    }
}

在这里插入图片描述

@ApiOperation(常用在Controller中的方法上表明方法的作用)

package com.yk.controller.medicine;

import com.yk.pojo.Medicine;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MediController {

    @ApiOperation("获取医疗信息")
    @PostMapping("/getMedicine")
    public Medicine getMedicine(){
        return new Medicine();
    }
}

在这里插入图片描述

ApiParam用于 Controller中的方法进行参数说明

package com.yk.controller.medicine;

import com.yk.pojo.Medicine;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MediController {

    @PostMapping("/getMedicine/{id}")
    public Medicine getMedicine(@ApiParam(value = "获取信息部门id",required = true) @PathVariable("id") String id){
        System.out.println(id);
        return new Medicine();
    }
}

在这里插入图片描述

@ApiModel和@ApiModelProperty(常用于实体类中说明,对应字段信息。当且仅当Controller类中有返回该实体类我们才能看到其注释信息)

package com.yk.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

@ApiModel("医疗保障组数据记录")
public class Medicine {

    @ApiModelProperty("小组编号")
    private String id;
    @ApiModelProperty("记录时间")
    private Date date;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
}

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ashes of time

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值