Skip to content

Script Executor

EasyApi includes a script executor that allows you to run Groovy scripts within the IDE context.

How to Use

  1. Open Code > EasyApi > ScriptExecutor (or Generate > EasyApi > ScriptExecutor on Windows/Linux)
  2. Write your Groovy script in the editor
  3. Click Run to execute

Available Context

Scripts have access to the following context objects:

ObjectAliasDescription
itCurrent context element (class, method, field)
loggerLOGLogging utility
toolTGeneral utility (string, collection, JSON, time)
regexRERegular expression utilities
configCConfiguration reader
filesFFile operations
helperHClass lookup and link resolution
runtimeRProject/module metadata
sessionS, sessionStorageSession-scoped key-value storage
localStoragePersistent key-value storage
httpClientHTTP client for making requests

Example Scripts

Inspect Current Class

groovy
logger.info("Class: ${it.name()}")
logger.info("Doc: ${it.doc()}")
logger.info("Has @RestController: ${it.hasAnn('org.springframework.web.bind.annotation.RestController')}")

Get Module Info

groovy
logger.info("Project: ${runtime.projectName()}")
logger.info("Module: ${runtime.module()}")
logger.info("File: ${runtime.filePath()}")

Use Tool Utilities

groovy
def json = tool.toJson(["name": it.name(), "path": runtime.filePath()])
logger.info(json)
tool.copy2Clipboard(json)

See Script Tools Reference for detailed documentation of all available tools.

Released under the Apache-2.0 License.