Skip to content

Param Rules

Rules for controlling how method parameters are named, documented, and displayed.

Available Rules

Rule KeyTypeAliasesDescription
param.namestringSet parameter name
param.typestringSet parameter type
param.docstring (merge distinct)doc.paramSet parameter documentation
param.requiredbooleanSet whether a parameter is required
param.ignorebooleanIgnore a parameter
param.default.valuestringSet parameter default value
param.demostringSet parameter demo/example value
param.mockstringSet parameter mock value
param.http.typestringSet parameter HTTP type (query/path/header/body)

Parameter Lifecycle Events

Rule KeyTypeAliasesDescription
api.param.parse.beforeeventparam.beforeBefore parsing a parameter
api.param.parse.aftereventparam.afterAfter parsing a parameter

param.name

Rename parameters in the documentation:

properties
param.name=groovy:it.ann("org.springframework.web.bind.annotation.RequestParam")?.value() ?: it.name()

param.type

Override parameter types:

properties
param.type=groovy:it.type().simpleName() == "MultipartFile" ? "file" : null

param.doc

Set parameter descriptions:

properties
param.doc=groovy:it.ann("io.swagger.annotations.ApiParam")?.value()

param.ignore

Exclude parameters from documentation:

properties
param.ignore=groovy:["HttpServletRequest","HttpServletResponse","Principal","Locale","InputStream","OutputStream"].contains(it.type().simpleName())

param.ignore=groovy:it.hasAnn("org.springframework.web.bind.annotation.CookieValue") && !it.hasAnn("io.swagger.annotations.ApiParam")

param.required

Mark parameters as required:

properties
param.required=groovy:it.ann("org.springframework.web.bind.annotation.RequestParam")?.required() ?: true

param.required=groovy:it.hasAnn("javax.validation.constraints.NotNull")||it.hasAnn("javax.validation.constraints.NotBlank")

param.default.value

Set default values for parameters:

properties
param.default.value=groovy:it.ann("org.springframework.web.bind.annotation.RequestParam")?.defaultValue()

param.default.value=groovy:it.ann("org.springframework.web.bind.annotation.PathVariable")?.value()

param.demo

Set demo/example values for parameters:

properties
param.demo=groovy:it.name() == "id" ? "1" : null

param.demo=groovy:it.type().simpleName() == "String" ? "example" : null

param.mock

Set mock values for parameters (used in Postman/HTTP client examples):

properties
param.mock=groovy:it.name() == "email" ? "user@example.com" : null

param.mock=groovy:it.type().simpleName() == "Integer" ? "1" : null

param.http.type

Override the HTTP parameter type:

properties
param.http.type=groovy:it.hasAnn("org.springframework.web.bind.annotation.RequestHeader") ? "header" : null

Released under the Apache-2.0 License.