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

Commit 2ade5c1

Browse files
committed
simpler access to option mapping, #68
1 parent 76bc812 commit 2ade5c1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/kotlin/io/openapiprocessor/core/converter/ApiOptions.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package io.openapiprocessor.core.converter
77

88
import io.openapiprocessor.core.converter.mapping.Mapping
9+
import io.openapiprocessor.core.converter.mapping.ResultStyleOptionMapping
10+
import io.openapiprocessor.core.processor.mapping.v2.ResultStyle
911
import io.openapiprocessor.core.support.Empty
1012

1113
/**
@@ -68,3 +70,20 @@ class ApiOptions {
6870
}
6971

7072
}
73+
74+
/**
75+
* get (global) result style option mapping value if set, otherwise [ResultStyle.SUCCESS].
76+
*
77+
* this is a shortcut to avoid the dependency on the
78+
* [io.openapiprocessor.core.converter.mapping.MappingFinder] for this *simple* case.
79+
*/
80+
val ApiOptions.resultStyle: ResultStyle
81+
get() {
82+
val matches = typeMappings
83+
.filterIsInstance(ResultStyleOptionMapping::class.java)
84+
85+
if (matches.isEmpty())
86+
return ResultStyle.SUCCESS
87+
88+
return matches.first().value
89+
}

0 commit comments

Comments
 (0)