Skip to content

Script Tools Overview

EasyYapi provides a set of built-in tools that can be used in Groovy scripts within configuration rules. These tools are automatically available as variables in all Groovy script contexts.

Available Tools

ToolDescription
itCurrent context object - the most important tool providing access to the element being processed
toolGeneral utility methods for string manipulation, collections, JSON, and more
regexRegular expression utilities with pattern caching for performance
loggerLogging utility for debugging and information output
helperCommon operation helpers for type resolution and other utilities
httpClientHTTP client for making requests in scripts
localStoragePersistent local storage that survives IDE restarts
sessionSession-level storage cleared when IDE is restarted
configConfiguration access for reading rule values
apiAPI utilities for modifying endpoint metadata
runtimeRuntime information about the environment
fieldContextField context utilities for JSON path operations
filesFile operations for reading and writing files

Usage

Tools are available as variables in Groovy scripts:

properties
field.mock=groovy:'''
if (it.type().name() == "java.lang.String") {
    return "mock_string"
}
logger.info("Generating mock for: " + it.name())
'''

Tool Categories

Context Tools

  • it - The primary context object. Its type depends on the rule context:
    • Class rules → ScriptPsiClassContext
    • Method rules → ScriptPsiMethodContext
    • Field rules → ScriptPsiFieldContext
    • Parameter rules → ScriptPsiParameterContext

Storage Tools

  • localStorage - Persistent storage that survives IDE restarts
  • session - Temporary storage cleared on IDE restart

Utility Tools

  • tool - String manipulation, collections, JSON operations
  • regex - Regular expression matching and extraction
  • helper - Type resolution and common operations
  • files - File I/O operations

Communication Tools

  • httpClient - HTTP requests
  • config - Configuration access
  • api - API endpoint modification

Information Tools

  • logger - Logging output
  • runtime - Environment information
  • fieldContext - JSON path context

See Also

  • Config Rules - How to use tools in configuration rules
  • Events - Event hooks where scripts can be used

Released under the Apache-2.0 License.