Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 76bc812

Browse files
committed
not the place to handle default fallback, #68
1 parent 622e4f5 commit 76bc812

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/main/kotlin/io/openapiprocessor/core/converter/mapping/MappingFinder.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,14 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
131131
/**
132132
* get (global) result style option mapping value.
133133
*
134-
* @return the [ResultStyle] if set, else the default value [ResultStyle.ALL]
134+
* @return the [ResultStyle] if set, otherwise null.
135135
*/
136-
fun findResultStyleMapping(): ResultStyle {
136+
fun findResultStyleMapping(): ResultStyle? {
137137
val matches = typeMappings
138138
.filterIsInstance(ResultStyleOptionMapping::class.java)
139139

140-
// default
141140
if (matches.isEmpty())
142-
return ResultStyle.SUCCESS
141+
return null
143142

144143
return matches.first().value
145144
}

src/test/kotlin/io/openapiprocessor/core/converter/mapping/MappingFinderSpec.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ class MappingFinderSpec: StringSpec({
280280
result.targetTypeName.shouldBe("org.openapitools.jackson.nullable.JsonNullable")
281281
}
282282

283+
"find unset result style option mapping" {
284+
val finder = MappingFinder(listOf())
285+
286+
val result = finder.findResultStyleMapping()
287+
288+
result.shouldBe(null)
289+
}
290+
283291
"find result style option mapping" {
284292
ResultStyle.values().forAll { style ->
285293
val finder = MappingFinder(listOf(ResultStyleOptionMapping(style)))

0 commit comments

Comments
 (0)