@@ -36,4 +36,69 @@ class MappingFinderEndpointMethodSpec: StringSpec({
36
36
result.targetTypeName.shouldBe("io.openapiprocessor.Foo ")
37
37
}
38
38
39
+ " endpoint/method parameter mapping matches single mapping" {
40
+ val finder = MappingFinder (
41
+ listOf(
42
+ EndpointTypeMapping ("/foo", null, emptyList()),
43
+ EndpointTypeMapping ("/foo", HttpMethod .GET , listOf(
44
+ ParameterTypeMapping ("foo param",
45
+ TypeMapping ("Foo ", "io.openapiprocessor.Foo ")),
46
+ ParameterTypeMapping ("far param",
47
+ TypeMapping ("far", "io.openapiprocessor.Far ")),
48
+ ParameterTypeMapping ("bar param",
49
+ TypeMapping ("Bar ", "io.openapiprocessor.Bar "))
50
+ )))
51
+ )
52
+
53
+ val info = SchemaInfo (foo, "far param", "", null, resolver)
54
+ val result = finder.findEndpointTypeMapping(info)
55
+
56
+ result.shouldNotBeNull()
57
+ result.sourceTypeName.shouldBe("far")
58
+ result.targetTypeName.shouldBe("io.openapiprocessor.Far ")
59
+ }
60
+
61
+ " endpoint/method response mapping matches single mapping" {
62
+ val finder = MappingFinder (
63
+ listOf(
64
+ EndpointTypeMapping ("/foo", null, emptyList()),
65
+ EndpointTypeMapping ("/foo", HttpMethod .GET , listOf(
66
+ ResponseTypeMapping ("application/json",
67
+ TypeMapping ("Foo ", "io.openapiprocessor.Foo ")),
68
+ ResponseTypeMapping ("application/json-2",
69
+ TypeMapping ("far", "io.openapiprocessor.Far ")),
70
+ ResponseTypeMapping ("application/json-3",
71
+ TypeMapping ("Bar ", "io.openapiprocessor.Bar "))
72
+ )))
73
+ )
74
+
75
+ val info = SchemaInfo (foo, "", "application/json",null, resolver)
76
+ val result = finder.findEndpointTypeMapping(info)
77
+
78
+ result.shouldNotBeNull()
79
+ result.sourceTypeName.shouldBe("Foo ")
80
+ result.targetTypeName.shouldBe("io.openapiprocessor.Foo ")
81
+ }
82
+
83
+ " endpoint type mapping matches null mapping" {
84
+ val finder = MappingFinder (
85
+ listOf(
86
+ EndpointTypeMapping ("/foo", null, emptyList()),
87
+ EndpointTypeMapping ("/foo", HttpMethod .PATCH , listOf(
88
+ NullTypeMapping ("null", "org.openapitools.jackson.nullable.JsonNullable "),
89
+ TypeMapping ("Far ", "io.openapiprocessor.Far "),
90
+ TypeMapping ("Bar ", "io.openapiprocessor.Bar ")
91
+ )))
92
+ )
93
+
94
+ val info = SchemaInfo (
95
+ SchemaInfo .Endpoint ("/foo", HttpMethod .PATCH ),
96
+ "Foo ", "", null, resolver)
97
+ val result = finder.findEndpointNullTypeMapping(info)
98
+
99
+ result.shouldNotBeNull()
100
+ result.sourceTypeName.shouldBe("null")
101
+ result.targetTypeName.shouldBe("org.openapitools.jackson.nullable.JsonNullable ")
102
+ }
103
+
39
104
})
0 commit comments