@@ -21,12 +21,14 @@ import com.github.hauner.openapi.spring.converter.mapping.ParameterTypeMapping
21
21
import com.github.hauner.openapi.spring.converter.mapping.TypeMapping
22
22
import com.github.hauner.openapi.spring.model.Api
23
23
import spock.lang.Specification
24
+ import spock.lang.Unroll
24
25
25
26
import static com.github.hauner.openapi.spring.support.OpenApiParser.parse
26
27
27
28
class DataTypeConverterParameterTypeMappingSpec extends Specification {
28
29
29
- void " converts object parameter schema to java type via endpoint mapping" () {
30
+ @Unroll
31
+ void " converts object parameter schema to java type via #type" () {
30
32
def openApi = parse (""" \
31
33
openapi: 3.0.2
32
34
info:
@@ -53,25 +55,40 @@ paths:
53
55
""" )
54
56
55
57
when :
56
- def options = new ApiOptions (
57
- packageName : ' pkg' ,
58
- typeMappings : [
59
- new EndpointTypeMapping (path : ' /foobar' ,
60
- typeMappings : [
61
- new ParameterTypeMapping (
62
- parameterName : ' foobar' ,
63
- mapping : new TypeMapping (
64
- sourceTypeName : ' object' ,
65
- targetTypeName : ' pkg.TargetClass' )
66
- )
67
- ])
68
- ])
58
+ def options = new ApiOptions (packageName : ' pkg' , typeMappings : mappings)
69
59
Api api = new ApiConverter (options). convert (openApi)
70
60
71
61
then :
72
62
def itf = api. interfaces. first ()
73
63
def ep = itf. endpoints. first ()
74
64
ep. parameters. first (). dataType. name == ' TargetClass'
65
+
66
+ where :
67
+ type << [
68
+ ' endpoint parameter mapping' ,
69
+ ' global parameter mapping'
70
+ ]
71
+
72
+ mappings << [
73
+ [
74
+ new EndpointTypeMapping (path : ' /foobar' ,
75
+ typeMappings : [
76
+ new ParameterTypeMapping (
77
+ parameterName : ' foobar' ,
78
+ mapping : new TypeMapping (
79
+ sourceTypeName : ' object' ,
80
+ targetTypeName : ' pkg.TargetClass' )
81
+ )
82
+ ])
83
+ ], [
84
+ new ParameterTypeMapping (
85
+ parameterName : ' foobar' ,
86
+ mapping : new TypeMapping (
87
+ sourceTypeName : ' object' ,
88
+ targetTypeName : ' pkg.TargetClass' )
89
+ )
90
+ ]
91
+ ]
75
92
}
76
93
77
94
}
0 commit comments