Skip to content

Commit a73bfcd

Browse files
committed
openapi-processor/openapi-processor-spring#126, test distinct consumes/produces
(cherry picked from commit 77b0be3)
1 parent 0ed9da0 commit a73bfcd

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/test/groovy/com/github/hauner/openapi/micronaut/writer/java/MappingAnnotationWriterSpec.groovy

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,48 @@ class MappingAnnotationWriterSpec extends Specification {
138138
target.toString () == """@Get(uri = "${endpoint.path}", consumes = {"multipart/form-data"})"""
139139
}
140140

141+
void "writes unique 'consumes' parameter" () {
142+
def endpoint = createEndpoint (path: '/foo', method: HttpMethod.GET, responses: [
143+
'204' : [new EmptyResponse ()]
144+
], requestBodies: [
145+
new RequestBody('body', 'foo/in', new StringDataType (),
146+
false, false),
147+
new RequestBody('body', 'foo/in', new StringDataType (),
148+
false, false),
149+
new RequestBody('body', 'foo/in', new StringDataType (),
150+
false, false)
151+
])
152+
153+
when:
154+
writer.write (target, endpoint, endpoint.endpointResponses.first ())
155+
156+
then:
157+
target.toString ().contains ('consumes = {"foo/in"}')
158+
}
159+
160+
void "writes unique 'produces' parameters" () {
161+
def endpoint = createEndpoint (path: '/foo', method: HttpMethod.GET, responses: [
162+
'200' : [
163+
new Response ('foo/out', new StringDataType (), null)
164+
],
165+
'400' : [
166+
new Response ('foo/out', new StringDataType (), null)
167+
],
168+
'401' : [
169+
new Response ('foo/out', new StringDataType (), null)
170+
],
171+
'403': [
172+
new Response ('foo/out', new StringDataType (), null)
173+
]
174+
])
175+
176+
when:
177+
writer.write (target, endpoint, endpoint.endpointResponses.first ())
178+
179+
then:
180+
target.toString ().contains ('produces = {"foo/out"}')
181+
}
182+
141183
@Deprecated
142184
private Endpoint createEndpoint (Map properties) {
143185
def ep = new Endpoint(

0 commit comments

Comments
 (0)