Skip to content

Commit

Permalink
Only emit RequestBodyObject when there is a request + fix required bo…
Browse files Browse the repository at this point in the history
…olean
  • Loading branch information
nsimonides committed Jan 20, 2025
1 parent 73ad064 commit 5e93da1
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,15 @@ object OpenApiV3Emitter : Emitter(noLogger) {
ParameterLocation.HEADER
)
},
requestBody = RequestBodyObject(
content = requests.mapNotNull { it.content?.emit() }.toMap().ifEmpty { null },
required = !requests.any { it.content?.isNullable ?: false }
),
requestBody = requests.mapNotNull { it.content?.emit() }
.toMap()
.takeIf { it.isNotEmpty() }
?.let { content ->
RequestBodyObject(
content = content,
required = requests.any { it.content?.isNullable == false }
)
},
responses = responses
.groupBy { it.status }
.map { (statusCode, res) ->
Expand Down

0 comments on commit 5e93da1

Please sign in to comment.