This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree 2 files changed +34
-0
lines changed
main/kotlin/io/openapiprocessor/core/converter/mapping
test/kotlin/io/openapiprocessor/core/converter/mapping
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ package io.openapiprocessor.core.converter.mapping
8
8
import io.openapiprocessor.core.converter.SchemaInfo
9
9
import io.openapiprocessor.core.converter.mapping.matcher.*
10
10
import io.openapiprocessor.core.model.HttpMethod
11
+ import io.openapiprocessor.core.processor.mapping.v2.ResultStyle
11
12
12
13
/* *
13
14
* find mappings of a given schema info in the type mapping list.
@@ -127,6 +128,24 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
127
128
return matches.first() as ResultTypeMapping
128
129
}
129
130
131
+ /* *
132
+ * get (global) result style option mapping value.
133
+ *
134
+ * @return the [ResultStyle] if set, else the default value [ResultStyle.ALL]
135
+ */
136
+ fun findResultStyleMapping (): ResultStyle {
137
+ val matches = typeMappings
138
+ .filterIsInstance(OptionMapping ::class .java)
139
+ .filter { it.name == " resultStyle" }
140
+ .map { it as OptionMapping <ResultStyle > }
141
+
142
+ // default
143
+ if (matches.isEmpty())
144
+ return ResultStyle .SUCCESS
145
+
146
+ return matches.first().value
147
+ }
148
+
130
149
/* *
131
150
* find (endpoint) "single" type mappings.
132
151
*
Original file line number Diff line number Diff line change @@ -7,13 +7,15 @@ package io.openapiprocessor.core.converter.mapping
7
7
8
8
import io.kotest.assertions.throwables.shouldThrow
9
9
import io.kotest.core.spec.style.StringSpec
10
+ import io.kotest.inspectors.forAll
10
11
import io.kotest.matchers.nulls.shouldBeNull
11
12
import io.kotest.matchers.nulls.shouldNotBeNull
12
13
import io.kotest.matchers.shouldBe
13
14
import io.mockk.mockk
14
15
import io.openapiprocessor.core.converter.SchemaInfo
15
16
import io.openapiprocessor.core.model.HttpMethod
16
17
import io.openapiprocessor.core.parser.RefResolver
18
+ import io.openapiprocessor.core.processor.mapping.v2.ResultStyle
17
19
18
20
class MappingFinderSpec : StringSpec ({
19
21
val resolver = mockk<RefResolver >()
@@ -278,4 +280,17 @@ class MappingFinderSpec: StringSpec({
278
280
result.targetTypeName.shouldBe("org.openapitools.jackson.nullable.JsonNullable ")
279
281
}
280
282
283
+ " find result style option mapping" {
284
+ listOf(
285
+ ResultStyle .ALL ,
286
+ ResultStyle .SUCCESS
287
+ ).forAll { style ->
288
+ val finder = MappingFinder (listOf(OptionMapping ("resultStyle", style)))
289
+
290
+ val result = finder.findResultStyleMapping()
291
+
292
+ result.shouldBe(style)
293
+ }
294
+ }
295
+
281
296
})
You can’t perform that action at this time.
0 commit comments