Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/openapi nonnull issue #3413

Merged
merged 5 commits into from
May 12, 2024
Merged
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 @@ -451,8 +451,10 @@ private static List<ParameterExt> routerArguments(
private static boolean isNullable(MethodNode method, int paramIndex) {
if (paramIndex < method.invisibleAnnotableParameterCount) {
List<AnnotationNode> annotations = method.invisibleParameterAnnotations[paramIndex];
return annotations.stream()
.anyMatch(a -> a.desc.equals("Lorg/jetbrains/annotations/Nullable;"));
if (annotations != null) {
return annotations.stream()
.anyMatch(a -> a.desc.equals("Lorg/jetbrains/annotations/Nullable;"));
}
}
return true;
}
Expand Down
27 changes: 27 additions & 0 deletions modules/jooby-openapi/src/test/java/issues/i3412/App3412.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package issues.i3412;

import edu.umd.cs.findbugs.annotations.NonNull;
import io.jooby.Jooby;
import io.jooby.OpenAPIModule;
import io.jooby.annotation.GET;
import io.jooby.annotation.Path;
import io.jooby.annotation.QueryParam;

public class App3412 extends Jooby {

@Path("/")
static class Controller {

@GET("/welcome")
public String sayHi(@QueryParam @NonNull String greeting, @QueryParam String language) {
return "hi";
}
}

{
install(new OpenAPIModule());

mvc(new Controller());

}
}
42 changes: 42 additions & 0 deletions modules/jooby-openapi/src/test/java/issues/i3412/Issue3412.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package issues.i3412;

import io.jooby.openapi.OpenAPIResult;
import io.jooby.openapi.OpenAPITest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue3412 {

@OpenAPITest(value = App3412.class)
public void shouldParseNonnullQueryParameter(OpenAPIResult result) {
assertEquals("""
openapi: 3.0.1
info:
title: 3412 API
description: 3412 API description
version: "1.0"
paths:
/welcome:
get:
operationId: sayHi
parameters:
- name: greeting
in: query
required: true
schema:
type: string
- name: language
in: query
schema:
type: string
responses:
"200":
description: Success
content:
application/json:
schema:
type: string
""",
result.toYaml());
}
}
Loading