Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 9c989c4

Browse files
committed
(cherry picked from commit 81e5eb0)
1 parent af9df18 commit 9c989c4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/main/kotlin/io/openapiprocessor/core/model/Endpoint.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ class Endpoint(
6060
}
6161

6262
/**
63-
* provides a list of all consumed content types of this endpoint including multipart/form-data.
63+
* provides a set of all consumed content types of this endpoint including multipart/form-data.
6464
*
6565
* multipart/form-data is special because a multipart request body with multiple properties is
6666
* converted to multiple {@link MultipartParameter}s in the internal model. The request body
6767
* information is no longer available.
6868
*
69-
* @return the list of content types
69+
* @return the set of content types
7070
*/
71-
fun getConsumesContentTypes(): List<String> {
71+
fun getConsumesContentTypes(): Set<String> {
7272
val contentTypes = requestBodies
7373
.map { it.contentType }
74-
.toSet()
75-
.toMutableList()
74+
.toMutableSet()
7675

7776
val multipart = parameters.find {
7877
it is MultipartParameter

src/test/groovy/com/github/hauner/openapi/core/model/EndpointContentTypesSpec.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class EndpointContentTypesSpec extends Specification {
2222
}
2323

2424
expect:
25-
endpoint.consumesContentTypes == []
25+
endpoint.consumesContentTypes == [] as Set
2626
}
2727

28-
void "provides consuming content types" () {
28+
void "provides distinct consuming content types" () {
2929
def endpoint = endpoint('/foo', HttpMethod.GET) { e ->
3030
e.parameters () { ps ->
3131
ps.body("body", "text/plain", new StringDataType())
@@ -56,7 +56,7 @@ class EndpointContentTypesSpec extends Specification {
5656
}
5757

5858
expect:
59-
endpoint.consumesContentTypes == ['multipart/form-data']
59+
endpoint.consumesContentTypes == ['multipart/form-data'] as Set
6060
}
6161

6262
void "provides no producing content types without response" () {

0 commit comments

Comments
 (0)