Skip to content

Commit 1d73056

Browse files
committed
fix: has parts is has request body ok
1 parent 8f51ffe commit 1d73056

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

restdocs-api-spec/src/main/kotlin/com/keecon/restdocs/apispec/ResourceSnippet.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.springframework.http.MediaType.APPLICATION_JSON
88
import org.springframework.restdocs.RestDocumentationContext
99
import org.springframework.restdocs.generate.RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE
1010
import org.springframework.restdocs.operation.Operation
11+
import org.springframework.restdocs.operation.OperationRequestPart
1112
import org.springframework.restdocs.payload.FieldDescriptor
1213
import org.springframework.restdocs.snippet.PlaceholderResolverFactory
1314
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory
@@ -46,7 +47,10 @@ class ResourceSnippet(private val resourceSnippetParameters: ResourceSnippetPara
4647
val operationId =
4748
propertyPlaceholderHelper.replacePlaceholders(operation.name, placeholderResolverFactory.create(context))
4849

49-
val hasRequestBody = operation.request.contentAsString.isNotEmpty()
50+
val hasRequestBody = operation.request.contentAsString.isNotEmpty() ||
51+
operation.request.parts?.stream()
52+
?.map(OperationRequestPart::getContentAsString)
53+
?.anyMatch { it.isNotEmpty() } ?: false
5054
val hasResponseBody = operation.response.contentAsString.isNotEmpty()
5155

5256
val securityRequirements = SecurityRequirementsHandler().extractSecurityRequirements(operation)

0 commit comments

Comments
 (0)