Skip to content

Commit c9c460a

Browse files
committed
GH-244 Add OpenApiNullable(nullable = false) example to tests
1 parent a5ce54b commit c9c460a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

openapi-annotation-processor/src/test/kotlin/io/javalin/openapi/processor/ComponentAnnotationsTest.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,31 @@ internal class ComponentAnnotationsTest : OpenApiAnnotationProcessorSpecificatio
7575
"""))
7676
}
7777

78-
private class ClassWithNullableProperty(
78+
private class ClassWithNullableProperties(
7979
@get:OpenApiNullable
80-
val testProperty: String
80+
val testProperty: String,
81+
@get:OpenApiNullable(nullable = false)
82+
val optionalProperty: String?,
8183
)
8284

8385
@OpenApi(
84-
path = "/nullable",
85-
versions = ["should_add_nullable_property"],
86-
responses = [OpenApiResponse(status = "200", content = [OpenApiContent(from = ClassWithNullableProperty::class)])]
86+
path = "/nullability",
87+
versions = ["should_control_nullability"],
88+
responses = [OpenApiResponse(status = "200", content = [OpenApiContent(from = ClassWithNullableProperties::class)])]
8789
)
8890
@Test
89-
fun should_add_nullable_property() = withOpenApi("should_add_nullable_property") {
91+
fun should_add_nullable_property() = withOpenApi("should_control_nullability") {
9092
println(it)
9193

9294
assertThatJson(it)
93-
.inPath("$.components.schemas.ClassWithNullableProperty.properties.testProperty")
95+
.inPath("$.components.schemas.ClassWithNullableProperties.properties.testProperty")
9496
.isObject
9597
.containsEntry("nullable", true)
98+
99+
assertThatJson(it)
100+
.inPath("$.components.schemas.ClassWithNullableProperties.properties.optionalProperty")
101+
.isObject
102+
.containsEntry("nullable", false)
96103
}
97104

98105
}

0 commit comments

Comments
 (0)