Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MigrateApiParamSchemaValue extends JavaIsoVisitor<ExecutionContext> {
@Override
public Annotation visitAnnotation(Annotation annotation, ExecutionContext ctx) {
J.Annotation a = super.visitAnnotation(annotation, ctx);
if (!PARAMETER_ANNOTATION_MATCHER.matches(a)) {
if (!PARAMETER_ANNOTATION_MATCHER.matches(a) || a.getArguments() == null) {
return a;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,56 @@ class Example {
);
}

@Test
void migrateApiParamWithoutArguments() {
rewriteRun(
//language=java
java(
"""
import io.swagger.annotations.ApiParam;

class Example {
@ApiParam
private Integer foo;
}
""",
"""
import io.swagger.v3.oas.annotations.Parameter;

class Example {
@Parameter
private Integer foo;
}
"""
)
);
}

@Test
void migrateApiParamWithoutArgumentsOnMethodParameter() {
rewriteRun(
//language=java
java(
"""
import io.swagger.annotations.ApiParam;

class Example {
void create(@ApiParam Integer foo) {
}
}
""",
"""
import io.swagger.v3.oas.annotations.Parameter;

class Example {
void create(@Parameter Integer foo) {
}
}
"""
)
);
}

/**
*
* Same test as {@link #migrateApiParam()} making sure the order of the annotation properties doesn't break the logic
Expand Down