Skip to content

Commit bc50fdd

Browse files
committed
#30, support "object @ io.oap.Annotation" mapping
1 parent 6e78dbb commit bc50fdd

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/MappingFinder.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
6060
return typeMappings
6161
.filterIsInstance<AnnotationTypeMapping>()
6262
.filter {
63+
val matchObject = it.sourceTypeName == "object"
6364
val matchType = it.sourceTypeName == type
6465
val matchFormat = it.sourceTypeFormat == format
65-
matchType && matchFormat
66+
67+
(matchType && matchFormat) || (matchObject && matchFormat)
6668
}
6769
}
6870

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/converter/MappingFinderAnnotationSpec.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ class MappingFinderAnnotationSpec: StringSpec({
2626
mapping.first().sourceTypeName shouldBe "Foo"
2727
}
2828

29+
"find 'object' type annotation mapping" {
30+
val finder = MappingFinder(listOf(
31+
AnnotationTypeMapping(
32+
"object", null,
33+
Annotation("annotation.Bar"))
34+
))
35+
36+
val mapping = finder.findTypeAnnotations("Foo")
37+
38+
mapping.size shouldBe 1
39+
mapping.first().sourceTypeName shouldBe "object"
40+
}
41+
2942
"find type:format annotation mapping" {
3043
val finder = MappingFinder(listOf(
3144
AnnotationTypeMapping(

0 commit comments

Comments
 (0)