Skip to content

Migrate springfox @ApiIgnore on parameters to @Parameter(hidden = true)#76

Merged
timtebeek merged 2 commits into
mainfrom
tim/hidden-param-to-parameter-hidden
May 22, 2026
Merged

Migrate springfox @ApiIgnore on parameters to @Parameter(hidden = true)#76
timtebeek merged 2 commits into
mainfrom
tim/hidden-param-to-parameter-hidden

Conversation

@timtebeek
Copy link
Copy Markdown
Member

Summary

The existing ChangeType: springfox.documentation.annotations.ApiIgnore -> io.swagger.v3.oas.annotations.Hidden step inside SwaggerToOpenAPI produces uncompilable code when @ApiIgnore sits on a controller parameter (Principal, HttpServletRequest, Pageable, ...), because @Hidden has @Target({METHOD, TYPE}) and cannot annotate a parameter.

This adds MigrateApiIgnoreParameterToParameterHidden, which converts parameter usages directly to @io.swagger.v3.oas.annotations.Parameter(hidden = true) and runs immediately before the generic ChangeType step so the pipeline never produces invalid intermediate state. Method- and class-level @ApiIgnore is left for the subsequent ChangeType to handle.

Test plan

  • New recipe unit tests: parameter replacement (@DocumentExample), method-level no-op, class-level no-op, multi-parameter targeting
  • Full ./gradlew test suite passes

…true)`

The existing `ChangeType: ApiIgnore -> Hidden` step in `SwaggerToOpenAPI`
produces uncompilable code when `@ApiIgnore` sits on a controller
parameter (e.g. `Principal`, `HttpServletRequest`), because
`io.swagger.v3.oas.annotations.Hidden` has `@Target({METHOD, TYPE})`.
Convert parameter usages directly to `@Parameter(hidden = true)` before
the generic `ChangeType` runs, leaving method- and class-level
`@ApiIgnore` for that step to handle.
@timtebeek timtebeek merged commit 706f8ed into main May 22, 2026
1 check passed
@timtebeek timtebeek deleted the tim/hidden-param-to-parameter-hidden branch May 22, 2026 13:33
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant