@@ -10,6 +10,7 @@ import io.kotest.matchers.collections.shouldHaveSize
1010import io.kotest.matchers.shouldBe
1111import io.openapiprocessor.core.converter.MappingFinderQuery
1212import io.openapiprocessor.core.converter.mapping.matcher.InterfaceTypeMatcher
13+ import io.openapiprocessor.core.converter.mapping.steps.ParametersStep
1314import io.openapiprocessor.core.converter.mapping.steps.TypesStep
1415import io.openapiprocessor.core.parser.HttpMethod
1516import io.openapiprocessor.core.processor.MappingReader
@@ -46,6 +47,34 @@ class MappingConverterInterfacesSpec: StringSpec({
4647 typeMappings[1 ].genericTypes[0 ].typeName shouldBe " java.lang.String"
4748 }
4849
50+ " read global interface parameter type mapping" {
51+ val yaml = """
52+ |openapi-processor-mapping: $VERSION
53+ |
54+ |options:
55+ | package-name: io.openapiprocessor.somewhere
56+ |
57+ |map:
58+ | parameters:
59+ | - type: Foo =+ java.io.Serializable
60+ | - type: Foo =+ some.other.Interface<java.lang.String>
61+ """ .trimMargin()
62+
63+ val mapping = reader.read(yaml) as Mapping
64+ val mappings = MappingConverter (mapping).convert().globalMappings
65+
66+ val query = MappingFinderQuery (path = "/foo", name = "Foo ")
67+ val typeMappings = mappings.findInterfaceParameterTypeMapping(
68+ InterfaceTypeMatcher (query), ParametersStep ("type"))
69+
70+ typeMappings shouldHaveSize 2
71+ typeMappings[0 ].sourceTypeName shouldBe " Foo"
72+ typeMappings[0 ].targetTypeName shouldBe " java.io.Serializable"
73+ typeMappings[1 ].sourceTypeName shouldBe " Foo"
74+ typeMappings[1 ].targetTypeName shouldBe " some.other.Interface"
75+ typeMappings[1 ].genericTypes[0 ].typeName shouldBe " java.lang.String"
76+ }
77+
4978 " read endpoint interface mappings" {
5079 val yaml = """
5180 |openapi-processor-mapping: $VERSION
@@ -75,6 +104,35 @@ class MappingConverterInterfacesSpec: StringSpec({
75104 typeMappings[1 ].genericTypes[0 ].typeName shouldBe " java.lang.String"
76105 }
77106
107+ " read endpoint parameter interface mappings" {
108+ val yaml = """
109+ |openapi-processor-mapping: $VERSION
110+ |
111+ |options:
112+ | package-name: io.openapiprocessor.somewhere
113+ |
114+ |map:
115+ | paths:
116+ | /foo:
117+ | parameters:
118+ | - type: Foo =+ java.io.Serializable
119+ | - type: Foo =+ some.other.Interface<java.lang.String>
120+ """ .trimMargin()
121+
122+ val mapping = reader.read (yaml) as Mapping
123+ val mappings = MappingConverter (mapping).convert().endpointMappings
124+
125+ val query = MappingFinderQuery (path = "/foo", name = "Foo ")
126+ val typeMappings = mappings[" /foo" ]!!.findInterfaceParameterTypeMapping(query, TypesStep ())
127+
128+ typeMappings shouldHaveSize 2
129+ typeMappings[0 ].sourceTypeName shouldBe " Foo"
130+ typeMappings[0 ].targetTypeName shouldBe " java.io.Serializable"
131+ typeMappings[1 ].sourceTypeName shouldBe " Foo"
132+ typeMappings[1 ].targetTypeName shouldBe " some.other.Interface"
133+ typeMappings[1 ].genericTypes[0 ].typeName shouldBe " java.lang.String"
134+ }
135+
78136 " read endpoint/method interface mappings" {
79137 val yaml = """
80138 |openapi-processor-mapping: $VERSION
0 commit comments