Skip to content

Groovy Local Extension ​

EasyApi supports Groovy scripts for advanced customization and extension.

Groovy Script Location ​

You can place Groovy scripts in the following locations:

  1. IDE Settings — Add scripts in Preferences(Settings) > Other Settings > EasyApi > Extensions tab
  2. Local Config File — Reference Groovy scripts from .easy.api.config or .easy.api.yml
  3. Script Executor — Run ad-hoc Groovy scripts via Code > EasyApi > ScriptExecutor

Using Groovy in Rules ​

Groovy scripts in rules have access to the current context object (it):

properties
field.ignore=groovy:it.name() == "password" || it.name() == "secret"

field.doc=groovy:it.ann("io.swagger.annotations.ApiModelProperty")?.value()

field.required=groovy:it.hasAnn("javax.validation.constraints.NotNull")

Available Context Objects ​

In Groovy rules, the following objects are available:

ObjectAliasDescription
it—Current rule context (class, method, field, or param)
loggerLOGLogging utility
toolTGeneral utility (string, collection, JSON, time, clipboard)
regexRERegular expression utilities
configCConfiguration reader
filesFFile operations
helperHClass lookup and link resolution
runtimeRProject/module metadata
sessionS, sessionStorageSession-scoped key-value storage
localStorage—Persistent key-value storage
httpClient—HTTP client for making requests
api—API endpoint context (available during export rules only)
fieldContext—Field path context (available in field rules)

See Script Tools Reference for detailed documentation of each tool.

Context-Specific it Methods ​

The it object provides different methods depending on the element type. See it for the full reference.

Released under the Apache-2.0 License.