@@ -127,6 +127,48 @@ class MappingAnnotationWriterSpec extends Specification {
127
127
target. toString () == """ @GetMapping(path = "${ endpoint.path} ", produces = {"${ endpoint.responses.'200'.first ().contentType} ", "${ endpoint.responses.'default'.first ().contentType} "})"""
128
128
}
129
129
130
+ void " writes unique 'consumes' parameter" () {
131
+ def endpoint = createEndpoint (path : ' /foo' , method : HttpMethod . GET , responses : [
132
+ ' 204' : [new EmptyResponse ()]
133
+ ], requestBodies : [
134
+ new RequestBody (' body' , ' foo/in' , new StringDataType (),
135
+ false , false ),
136
+ new RequestBody (' body' , ' foo/in' , new StringDataType (),
137
+ false , false ),
138
+ new RequestBody (' body' , ' foo/in' , new StringDataType (),
139
+ false , false )
140
+ ])
141
+
142
+ when :
143
+ writer. write (target, endpoint, endpoint. endpointResponses. first ())
144
+
145
+ then :
146
+ target. toString (). contains (' consumes = {"foo/in"}' )
147
+ }
148
+
149
+ void " writes unique 'produces' parameters" () {
150
+ def endpoint = createEndpoint (path : ' /foo' , method : HttpMethod . GET , responses : [
151
+ ' 200' : [
152
+ new Response (' foo/out' , new StringDataType (), null )
153
+ ],
154
+ ' 400' : [
155
+ new Response (' foo/out' , new StringDataType (), null )
156
+ ],
157
+ ' 401' : [
158
+ new Response (' foo/out' , new StringDataType (), null )
159
+ ],
160
+ ' 403' : [
161
+ new Response (' foo/out' , new StringDataType (), null )
162
+ ]
163
+ ])
164
+
165
+ when :
166
+ writer. write (target, endpoint, endpoint. endpointResponses. first ())
167
+
168
+ then :
169
+ target. toString (). contains (' produces = {"foo/out"}' )
170
+ }
171
+
130
172
@Deprecated
131
173
private Endpoint createEndpoint (Map properties ) {
132
174
def ep = new Endpoint (
0 commit comments