Yapi api管理系统

一、Ypai介绍
高效、易用、功能强大的API管理平台旨在为开发、产品、测试人员提供更优雅的接口管理服务。
1、提供基本的项目分组,项目管理,接口管理功能;
2、友好的接口文档,基于websocket的多人协作接口编辑功能和类postman测试工具,让多人协作成倍提升开发效率;
3、基于Mockjs,使用简单功能强大的mock服务;

二、yapi官方使用文档地址
https://hellosean1025.github.io/yapi/


三、推荐IntelliJ IDEA对接yapi优秀插件EasyYapi
3.1、EasyYapi官方帮助文档地址:https://easyyapi.com/index.html

3.2、EasyYapi备注IntelliJ IDEA模板推荐设置
1、类注释
/**
 * 
 * 
 * @author xx.xx
 * @date $date$ $time$
 **/

2、方法注释
/**
 *  
 * 
 * @author xx.xx
 * @date $date$ $time$ 
$param$
 * @return $return$
**/

IntelliJ IDEA param 入参多行注释脚本:
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+= ' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n':'')}; return result", methodParameters()) 

Yapi接口管理系统分享

一、Ypai介绍
高效、易用、功能强大的API管理平台旨在为开发、产品、测试人员提供更优雅的接口管理服务。
1、提供基本的项目分组,项目管理,接口管理功能;
2、友好的接口文档,基于websocket的多人协作接口编辑功能和类postman测试工具,让多人协作成倍提升开发效率;
3、基于Mockjs,使用简单功能强大的mock服务;

二、yapi官方使用文档地址
https://hellosean1025.github.io/yapi/


三、推荐IntelliJ IDEA对接yapi优秀插件EasyYapi
3.1、EasyYapi官方帮助文档地址:https://easyyapi.com/index.html

3.2、EasyYapi备注IntelliJ IDEA模板推荐设置
1、类注释
/**
 * 
 * 
 * @author qing.wang
 * @date $date$ $time$
 **/

2、方法注释
/**
 *  
 * 
 * @author qing.wang
 * @date $date$ $time$ 
$param$
 * @return $return$
**/

IntelliJ IDEA param 入参多行注释脚本:
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+= ' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n':'')}; return result", methodParameters()) 


3、EasyYapi插件推荐全局配置(具体使用方法,参考3.1、EasyYapi官方帮助)

#[module]
#Get the module from the comment,group the apis
module=#module

#[ignore]
#Ignore class/api
ignore=#ignore

#[deprecated_java]
#deprecated info(java)

doc.method[#deprecated]=groovy:"\n「已废弃」" + it.doc("deprecated")
doc.method[@java.lang.Deprecated]=「已废弃」

doc.method[groovy:it.containingClass().hasDoc("deprecated")]=groovy:"\n「已废弃」" + it.containingClass().doc("deprecated")
doc.method[groovy:it.containingClass().hasAnn("java.lang.Deprecated")]=「已废弃」

doc.field[#deprecated]=groovy:"\n「已废弃」" + it.doc("deprecated")
doc.field[@java.lang.Deprecated]=「已废弃」

#[deprecated_kotlin]
#deprecated info(kotlin)

doc.method[@kotlin.Deprecated]=groovy:"\n「已废弃」" + it.ann("kotlin.Deprecated","message")
doc.method[groovy:it.containingClass().hasAnn("kotlin.Deprecated")]=groovy:"\n「已废弃」 " + it.containingClass().ann("kotlin.Deprecated","message")
doc.field[@kotlin.Deprecated]=groovy:"\n「已废弃」" + it.ann("kotlin.Deprecated","message")

#[Jackson]
#Support for Jackson annotations
json.rule.field.name=@com.fasterxml.jackson.annotation.JsonProperty#value
json.rule.field.ignore=@com.fasterxml.jackson.annotation.JsonIgnore#value

#[Gson]
#Support for Gson annotations
[email protected]#value
[email protected]#serialize

#[ignore_transient_field]
#ignore transient field
json.rule.field.ignore=groovy:it.hasModifier("transient")

#[converts]
#The ObjectId and Date are parsed as strings
json.rule.convert[org.bson.types.ObjectId]=java.lang.String
json.rule.convert[java.util.Date]=java.lang.String
json.rule.convert[java.sql.Timestamp]=java.lang.String
json.rule.convert[java.time.LocalDateTime]=java.lang.String
json.rule.convert[java.time.LocalDate]=java.lang.String

#[spring_Entity]
#resolve HttpEntity/RequestEntity/ResponseEntity
###set resolveProperty = false
json.rule.convert[#regex:org.springframework.http.HttpEntity]=java.lang.Object
json.rule.convert[#regex:org.springframework.http.HttpEntity<(.*?)>]=${1}
json.rule.convert[#regex:org.springframework.http.RequestEntity<(.*?)>]=${1}
json.rule.convert[#regex:org.springframework.http.RequestEntity]=java.lang.Object
json.rule.convert[#regex:org.springframework.http.ResponseEntity<(.*?)>]=${1}
json.rule.convert[#regex:org.springframework.http.ResponseEntity]=java.lang.Object
###set resolveProperty = true

#[spring_webflux]
#resolve Mono/Flux
###set resolveProperty = false
json.rule.convert[#regex:reactor.core.publisher.Mono<(.*?)>]=${1}
json.rule.convert[#regex:reactor.core.publisher.Mono]=java.lang.Object
json.rule.convert[#regex:reactor.core.publisher.Flux<(.*?)>]=java.util.List<${1}>
json.rule.convert[#regex:reactor.core.publisher.Flux]=java.util.List
###set resolveProperty = true

#[javax.validation]
#Support for javax.validation annotations
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

#[is_file]
#Support spring file
type.is_file=groovy:it.isExtend("org.springframework.web.multipart.MultipartFile")

#[yapi_tag]
#yapi tag
api.tag[@java.lang.Deprecated]=deprecated
api.tag[#deprecated]=deprecated
api.tag[groovy:it.containingClass().hasAnn("java.lang.Deprecated")]=deprecated
api.tag[groovy:it.containingClass().hasDoc("deprecated")]=deprecated

#[yapi_tag_kotlin]
#yapi tag for kotlin
api.tag[@kotlin.Deprecated]=deprecated
api.tag[groovy:it.containingClass().hasAnn("kotlin.Deprecated")]=deprecated

#[yapi_status]
#yapi status
api.status[#undone]=undone
api.status[#todo]=undone

#[yapi_mock]
#yapi mock
field.mock=#mock


#[import_spring_properties]
#Import spring properties
###set ignoreNotFoundFile = true
###set ignoreUnresolved = true
properties.additional=${module_path}/src/main/resources/application.properties
properties.additional=${module_path}/src/main/resources/application.yml
properties.additional=${module_path}/src/main/resources/application.yaml
###set ignoreUnresolved = false
###set ignoreNotFoundFile = false

#[resolve_spring_properties]
#Resolve spring properties
###set ignoreUnresolved = true
class.prefix.path=${server.servlet.context-path}
###set ignoreUnresolved = false

#[ignore_serialVersionUID]
#ignore serialVersionUID
constant.field.ignore=serialVersionUID

#[support_mock_for_general]

#mock for date

###set resolveMulti = first
java_date_types=["java.util.Date","java.sql.Timestamp","java.time.LocalDate","java.time.LocalDateTime"]
field.mock[groovy:${java_date_types}.contains(it.type().name())&&it.jsonType().name()=="java.lang.String"] = groovy:"@date"
field.mock[groovy:${java_date_types}.contains(it.type().name())&&it.jsonType().name()=="java.lang.Long"] = groovy:"@timestamp@string(\"number\", 3)"
###set resolveMulti = error

#[private_protected_field_only]
#only keep private/protected field
json.rule.field.ignore=groovy:!(it.hasModifier("private")||it.hasModifier("protected"))

#[support_mock_for_javax_validation]

# mock for javax.validation

###set resolveMulti = first
# define var
number_min=-9999
number_max=9999
float_dmin=2
java_integer_types=["java.lang.Integer","int","java.lang.Long","long","java.lang.Short","short","java.math.BigInteger"]
java_float_types=["java.lang.Float","float","java.lang.Double","double","java.math.BigDecimal"]
# mock_integer_or_float=${java_integer_types}.contains(it.type().name())?"@integer":"@float"

# AssertTrue|AssertFalse|Email
field.mock[@javax.validation.constraints.AssertTrue]=true
field.mock[@javax.validation.constraints.AssertFalse]=false
field.mock[@javax.validation.constraints.Email]=groovy:"@email"

# Positive&PositiveOrZero
field.mock[groovy:it.hasAnn("javax.validation.constraints.Positive")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer(1,${number_max})"
field.mock[groovy:it.hasAnn("javax.validation.constraints.PositiveOrZero")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer(0,${number_max})"
field.mock[groovy:it.hasAnn("javax.validation.constraints.Positive")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(0.01,${number_max},${float_dmin})"
field.mock[groovy:it.hasAnn("javax.validation.constraints.PositiveOrZero")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(0,${number_max},${float_dmin})"

# Negative&NegativeOrZero
field.mock[groovy:it.hasAnn("javax.validation.constraints.Negative")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer(${number_min},-1)"
field.mock[groovy:it.hasAnn("javax.validation.constraints.NegativeOrZero")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer(${number_min},0)"
field.mock[groovy:it.hasAnn("javax.validation.constraints.Negative")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(${number_min},0.01,${float_dmin})"
field.mock[groovy:it.hasAnn("javax.validation.constraints.NegativeOrZero")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(${number_min},0,${float_dmin})"

# Max+Min
field.mock[groovy:it.hasAnn("javax.validation.constraints.Max")&&it.hasAnn("javax.validation.constraints.Min")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer("+it.ann("javax.validation.constraints.Min")+","+it.ann("javax.validation.constraints.Max")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.Max")&&it.hasAnn("javax.validation.constraints.Min")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float("+it.ann("javax.validation.constraints.Min")+","+it.ann("javax.validation.constraints.Max")+",${float_dmin})"

# Max|Min
field.mock[groovy:it.hasAnn("javax.validation.constraints.Max")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer(0,"+it.ann("javax.validation.constraints.Max")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.Min")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer("+it.ann("javax.validation.constraints.Min")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.Max")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(0,"+it.ann("javax.validation.constraints.Max")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.Min")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float("+it.ann("javax.validation.constraints.Min")+")"

# DecimalMax+DecimalMin
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMax")&&it.hasAnn("javax.validation.constraints.DecimalMin")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer("+it.ann("javax.validation.constraints.DecimalMin")+","+it.ann("javax.validation.constraints.DecimalMax")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMax")&&it.hasAnn("javax.validation.constraints.DecimalMin")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float("+it.ann("javax.validation.constraints.DecimalMin")+","+it.ann("javax.validation.constraints.DecimalMax")+",${float_dmin})"

# DecimalMax|DecimalMin
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMax")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer(0,"+it.ann("javax.validation.constraints.DecimalMax")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMin")&&${java_integer_types}.contains(it.jsonType().name())]=groovy:"@integer("+it.ann("javax.validation.constraints.DecimalMin")+")"
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMax")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(0,"+it.ann("javax.validation.constraints.DecimalMax")+",${float_dmin})"
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMin")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float("+it.ann("javax.validation.constraints.DecimalMin")+",${float_dmin})"

###set resolveMulti = error

#swagger
[email protected]#value
[email protected]#defaultValue
[email protected]#required
[email protected]#hidden
[email protected]#value
[email protected]#value
[email protected]#value
[email protected]#tags

 

 

你可能感兴趣的:(Yapi api管理系统)