1
+ /*
2
+ *
3
+ * Copyright 2015-2016 the original author or authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ *
18
+ */
1
19
package springfox.documentation.schema
20
+
21
+ import com.google.common.collect.ImmutableSet
2
22
import springfox.documentation.schema.mixins.ModelProviderSupport
3
23
import springfox.documentation.schema.mixins.TypesForTestingSupport
4
24
@@ -8,27 +28,35 @@ import static springfox.documentation.spi.schema.contexts.ModelContext.*
8
28
class BeanWithFactoryMethodSpec extends SchemaSpecification {
9
29
def " Type with bean properties in the constructor" () {
10
30
given :
11
- def sut = defaultModelProvider()
12
- def typeToTest = typeWithConstructorProperties()
13
- def reqContext = inputParam(typeToTest, documentationType, alternateTypeProvider(), new
14
- DefaultGenericTypeNamingStrategy ())
15
- def resContext = returnValue(typeToTest, documentationType, alternateTypeProvider(), new
16
- DefaultGenericTypeNamingStrategy ())
31
+ def sut = defaultModelProvider()
32
+ def typeToTest = typeWithConstructorProperties()
33
+ def reqContext = inputParam(
34
+ typeToTest,
35
+ documentationType,
36
+ alternateTypeProvider(),
37
+ new DefaultGenericTypeNamingStrategy (),
38
+ ImmutableSet . builder(). build())
39
+ def resContext = returnValue(
40
+ typeToTest,
41
+ documentationType,
42
+ alternateTypeProvider(),
43
+ new DefaultGenericTypeNamingStrategy (),
44
+ ImmutableSet . builder(). build())
17
45
18
46
when :
19
- def models = [sut. modelFor(reqContext). get(), sut. modelFor(resContext). get()]
47
+ def models = [sut. modelFor(reqContext). get(), sut. modelFor(resContext). get()]
20
48
21
49
then :
22
- models. each {
23
- it. properties. size() == 2
24
- it. properties. containsKey(fieldName)
25
- it. properties. " $fieldName " . description == description
26
- it. properties. " $fieldName " . required == isRequired
27
- it. properties. " $fieldName " . type. erasedType == type
28
- it. properties. " $fieldName " . qualifiedType == qualifiedTypeName
29
- it. properties. " $fieldName " . allowableValues == allowableValues
30
- true
31
- }
50
+ models. each {
51
+ it. properties. size() == 2
52
+ it. properties. containsKey(fieldName)
53
+ it. properties. " $fieldName " . description == description
54
+ it. properties. " $fieldName " . required == isRequired
55
+ it. properties. " $fieldName " . type. erasedType == type
56
+ it. properties. " $fieldName " . qualifiedType == qualifiedTypeName
57
+ it. properties. " $fieldName " . allowableValues == allowableValues
58
+ true
59
+ }
32
60
33
61
where :
34
62
fieldName || description | isRequired | type | qualifiedTypeName | allowableValues
@@ -38,27 +66,35 @@ class BeanWithFactoryMethodSpec extends SchemaSpecification {
38
66
39
67
def "Type with delegated constructor (factory method )" () {
40
68
given:
41
- def sut = defaultModelProvider()
42
- def typeToTest = typeWithDelegatedConstructor()
43
- def reqContext = inputParam(typeToTest, documentationType, alternateTypeProvider(), new
44
- DefaultGenericTypeNamingStrategy())
45
- def resContext = returnValue(typeToTest, documentationType, alternateTypeProvider(), new
46
- DefaultGenericTypeNamingStrategy())
69
+ def sut = defaultModelProvider()
70
+ def typeToTest = typeWithDelegatedConstructor()
71
+ def reqContext = inputParam(
72
+ typeToTest,
73
+ documentationType,
74
+ alternateTypeProvider(),
75
+ new DefaultGenericTypeNamingStrategy(),
76
+ ImmutableSet.builder().build())
77
+ def resContext = returnValue(
78
+ typeToTest,
79
+ documentationType,
80
+ alternateTypeProvider(),
81
+ new DefaultGenericTypeNamingStrategy(),
82
+ ImmutableSet.builder().build())
47
83
48
84
when:
49
- def models = [sut.modelFor(reqContext).get(), sut.modelFor(resContext).get()]
85
+ def models = [sut.modelFor(reqContext).get(), sut.modelFor(resContext).get()]
50
86
51
87
then:
52
- models.each {
53
- it.properties.size() == 2
54
- it.properties.containsKey(fieldName)
55
- it.properties." $fieldName" .description == description
56
- it.properties." $fieldName" .required == isRequired
57
- it.properties." $fieldName" .type.erasedType == type
58
- it.properties." $fieldName" .qualifiedType == qualifiedTypeName
59
- it.properties." $fieldName" .allowableValues == allowableValues
60
- true
61
- }
88
+ models.each {
89
+ it.properties.size() == 2
90
+ it.properties.containsKey(fieldName)
91
+ it.properties." $fieldName" .description == description
92
+ it.properties." $fieldName" .required == isRequired
93
+ it.properties." $fieldName" .type.erasedType == type
94
+ it.properties." $fieldName" .qualifiedType == qualifiedTypeName
95
+ it.properties." $fieldName" .allowableValues == allowableValues
96
+ true
97
+ }
62
98
63
99
where:
64
100
fieldName || description | isRequired | type | qualifiedTypeName | allowableValues
@@ -68,27 +104,35 @@ class BeanWithFactoryMethodSpec extends SchemaSpecification {
68
104
69
105
def " Type with @JsonCreator marked constructor" () {
70
106
given:
71
- def sut = defaultModelProvider()
72
- def typeToTest = typeWithDelegatedConstructor()
73
- def reqContext = inputParam(typeToTest, documentationType, alternateTypeProvider(), new
74
- DefaultGenericTypeNamingStrategy())
75
- def resContext = returnValue(typeToTest, documentationType, alternateTypeProvider(), new
76
- DefaultGenericTypeNamingStrategy())
107
+ def sut = defaultModelProvider()
108
+ def typeToTest = typeWithDelegatedConstructor()
109
+ def reqContext = inputParam(
110
+ typeToTest,
111
+ documentationType,
112
+ alternateTypeProvider(),
113
+ new DefaultGenericTypeNamingStrategy(),
114
+ ImmutableSet.builder().build())
115
+ def resContext = returnValue(
116
+ typeToTest,
117
+ documentationType,
118
+ alternateTypeProvider(),
119
+ new DefaultGenericTypeNamingStrategy(),
120
+ ImmutableSet.builder().build())
77
121
78
122
when:
79
- def models = [sut.modelFor(reqContext).get(), sut.modelFor(resContext).get()]
123
+ def models = [sut.modelFor(reqContext).get(), sut.modelFor(resContext).get()]
80
124
81
125
then:
82
- models.each {
83
- it.properties.size() == 2
84
- it.properties.containsKey(fieldName)
85
- it.properties." $fieldName" .description == description
86
- it.properties." $fieldName" .required == isRequired
87
- it.properties." $fieldName" .type.erasedType == type
88
- it.properties." $fieldName" .qualifiedType == qualifiedTypeName
89
- it.properties." $fieldName" .allowableValues == allowableValues
90
- true
91
- }
126
+ models.each {
127
+ it.properties.size() == 2
128
+ it.properties.containsKey(fieldName)
129
+ it.properties." $fieldName" .description == description
130
+ it.properties." $fieldName" .required == isRequired
131
+ it.properties." $fieldName" .type.erasedType == type
132
+ it.properties." $fieldName" .qualifiedType == qualifiedTypeName
133
+ it.properties." $fieldName" .allowableValues == allowableValues
134
+ true
135
+ }
92
136
93
137
where:
94
138
fieldName || description | isRequired | type | qualifiedTypeName | allowableValues
0 commit comments