Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.github.lcomment.example.service.ExampleService
import io.github.lcomment.korestdocs.mockmvc.KorestDocumentationExtension
import io.github.lcomment.korestdocs.mockmvc.documentation
import io.github.lcomment.korestdocs.mockmvc.extensions.andDocument
import io.github.lcomment.korestdocs.mockmvc.extensions.multipartWithDocs
import io.github.lcomment.korestdocs.mockmvc.extensions.requestWithDocs
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -149,7 +150,7 @@ internal class ApiSpec {
val image2 = MockMultipartFile("images", "", "image/png", "image2".toByteArray())
val request = ExampleMultipartRequest(listOf(image1, image2))

mockMvc.multipart(HttpMethod.POST, "/example") {
mockMvc.multipartWithDocs(HttpMethod.POST, "/example") {
header(HttpHeaders.AUTHORIZATION, "Bearer access-token")
file(image1)
file(image2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ abstract class FieldsSpec : DocumentSpec {
this.field(path, description, example, T::class, attributes)
}

inline fun <reified T : Any> ignoredField(
path: String,
description: String?,
example: T,
attributes: Map<String, Any> = mapOf("optional" to false, "ignored" to true),
) {
this.field(path, description, example, T::class, attributes)
}

inline fun <reified T : Any> subsectionField(
path: String,
description: String?,
Expand All @@ -71,6 +62,8 @@ abstract class FieldsSpec : DocumentSpec {
attributes: Map<String, Any>,
)

abstract fun ignoredField(path: String)

abstract fun <T : Any> subsectionField(
path: String,
description: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class FieldsSpecBuilder(
add(descriptor)
}

override fun ignoredField(
path: String,
) {
val descriptor = PayloadDocumentation.fieldWithPath(path).ignored()

add(descriptor)
}

override fun <T : Any> subsectionField(
path: String,
description: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ internal class FieldsSpecTest : DescribeSpec({
it("fieldsSpec should have one field") {
fieldsSpec.ignoredField(
path = "test",
description = "test",
example = example,
)

fieldsSpec.fields.size shouldBe 1
fieldsSpec.fields["test"] shouldBe example
fieldsSpec.fields.size shouldBe 0
fieldsSpec.fields["test"] shouldBe null
}
}
}
Expand Down
Loading