Skip to content

2. Supported custom rules

tangcent edited this page Aug 10, 2019 · 1 revision

supported rules

rule key context version desc
module class v0.7.2+ how to group api
ignore class/method v0.7.2+ ignore api in class
json.rule.field.name field v0.7.2+ the property name for field
json.rule.field.ignore field v0.7.2+ ignore field
json.rule.convert - v0.7.2+ the property type for field
doc.field field v0.7.2+ the additional doc for field
doc.method method v0.7.2+ the additional doc for method
param.required arg v0.7.3+ the param is required(must not be null)
field.required field v0.7.3+ the field is required(must not be null)

simple rule

  • # indicates read from comment tag
  • @ indicates read from annotation
    • @xxx means getting the value from the XXX annotation of a method or field
    • The @xxx#yyy representation gets the value from the yyy attribute of the XXX annotation of a method or field

script rule

Supported script types

  1. groovy rule(recommend): groovy:script
  2. js rule: js:script
  • Since JDK11 may be missing, it is recommended to use groovy as the first choice.

Supported methods

  • support context:it

  • support method in it:

    • it.name():String
    • it.hasAnn("annotation_name"):Boolean
    • it.ann("annotation_name"):String?
    • it.ann("annotation_name","attr"):String?
    • it.doc():String
    • it.doc("tag"):String?
    • it.doc("tag","subTag"):String?
    • it.hasDoc("tag"):Boolean
  • additional

    • if it is class

      • it.methods():method[]
      • it.methodCnt():int
      • it.field():field[]
      • it.fieldCnt():int
      • it.isExtend("cls"):Boolean
      • it.isMap():Boolean
      • it.isCollection():Boolean
      • it.isArray():Boolean
    • if it is method

      • it.returnType():class
      • it.isVarArgs():Boolean
      • it.args():arg[]
      • it.argTypes():class[]
      • it.argCnt():int
      • it.containingClass():class
    • if it is field

      • it.type():class
      • it.containingClass():class
      • it.jsonName():String
    • if it is arg

      • it.name():String
      • it.type():class
      • it.isVarArgs():Boolean