@@ -7,6 +7,7 @@ package io.openapiprocessor.core.converter.mapping
7
7
8
8
import io.openapiprocessor.core.converter.SchemaInfo
9
9
import io.openapiprocessor.core.converter.mapping.matcher.*
10
+ import io.openapiprocessor.core.model.HttpMethod
10
11
11
12
/* *
12
13
* find mappings of a given schema info in the type mapping list.
@@ -21,7 +22,7 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
21
22
* @throws AmbiguousTypeMappingException if there is more than one match.
22
23
*/
23
24
fun findEndpointTypeMapping (info : SchemaInfo ): TypeMapping ? {
24
- val ep = filterMappings(EndpointTypeMatcher (info.getPath()), typeMappings)
25
+ val ep = filterMappings(EndpointTypeMatcher (info.getPath(), info.getMethod() ), typeMappings)
25
26
26
27
val parameter = getTypeMapping(filterMappings(ParameterTypeMatcher (info), ep))
27
28
if (parameter != null )
@@ -71,8 +72,8 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
71
72
* @return the matching mapping or null if there is no match.
72
73
* @throws AmbiguousTypeMappingException if there is more than one match.
73
74
*/
74
- fun findEndpointAddParameterTypeMappings (path : String ): List <AddParameterTypeMapping > {
75
- return filterMappings(EndpointTypeMatcher (path), typeMappings)
75
+ fun findEndpointAddParameterTypeMappings (path : String , method : HttpMethod ): List <AddParameterTypeMapping > {
76
+ return filterMappings(EndpointTypeMatcher (path, method ), typeMappings)
76
77
.filterIsInstance<AddParameterTypeMapping >()
77
78
}
78
79
@@ -83,7 +84,7 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
83
84
* @return the "result" type mappings or null if there is no match.
84
85
*/
85
86
fun findEndpointResultTypeMapping (info : SchemaInfo ): ResultTypeMapping ? {
86
- val ep = filterMappings(EndpointTypeMatcher (info.getPath()), typeMappings)
87
+ val ep = filterMappings(EndpointTypeMatcher (info.getPath(), info.getMethod() ), typeMappings)
87
88
88
89
val matches = filterMappings({ _: ResultTypeMapping -> true }, ep)
89
90
if (matches.isEmpty())
@@ -112,7 +113,7 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
112
113
* @return the "single" type mappings or null if there is no match.
113
114
*/
114
115
fun findEndpointSingleTypeMapping (info : SchemaInfo ): TypeMapping ? {
115
- val ep = filterMappings(EndpointTypeMatcher (info.getPath()), typeMappings)
116
+ val ep = filterMappings(EndpointTypeMatcher (info.getPath(), info.getMethod() ), typeMappings)
116
117
117
118
val matches = filterMappings(SingleTypeMatcher (), ep)
118
119
if (matches.isEmpty())
@@ -141,7 +142,7 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
141
142
* @return the "multi" type mappings or null if there is no match.
142
143
*/
143
144
fun findEndpointMultiTypeMapping (info : SchemaInfo ): TypeMapping ? {
144
- val ep = filterMappings(EndpointTypeMatcher (info.getPath()), typeMappings)
145
+ val ep = filterMappings(EndpointTypeMatcher (info.getPath(), info.getMethod() ), typeMappings)
145
146
146
147
val matches = filterMappings(MultiTypeMatcher (), ep)
147
148
if (matches.isEmpty())
@@ -169,10 +170,10 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
169
170
* @param path the endpoint path
170
171
* @return true/false
171
172
*/
172
- fun isExcludedEndpoint (path : String ): Boolean {
173
+ fun isExcludedEndpoint (path : String , method : HttpMethod ): Boolean {
173
174
val ep = typeMappings
174
175
.filterIsInstance<EndpointTypeMapping >()
175
- .filter(EndpointTypeMatcher (path))
176
+ .filter(EndpointTypeMatcher (path, method ))
176
177
177
178
if (ep.isEmpty())
178
179
return false
@@ -189,7 +190,7 @@ class MappingFinder(private val typeMappings: List<Mapping> = emptyList()) {
189
190
* @return the "null" type mappings or null if there is no match.
190
191
*/
191
192
fun findEndpointNullTypeMapping (info : SchemaInfo ): NullTypeMapping ? {
192
- val ep = filterMappings(EndpointTypeMatcher (info.getPath()), typeMappings)
193
+ val ep = filterMappings(EndpointTypeMatcher (info.getPath(), info.getMethod() ), typeMappings)
193
194
194
195
val matches = filterMappings(NullTypeMatcher (), ep)
195
196
if (matches.isEmpty())
0 commit comments