diff --git a/example/src/test/kotlin/io/github/lcomment/example/controller/ApiSpec.kt b/example/src/test/kotlin/io/github/lcomment/example/controller/ApiSpec.kt index 7dd73f8..2d955c2 100644 --- a/example/src/test/kotlin/io/github/lcomment/example/controller/ApiSpec.kt +++ b/example/src/test/kotlin/io/github/lcomment/example/controller/ApiSpec.kt @@ -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 @@ -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) diff --git a/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpec.kt b/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpec.kt index 76baf39..b7e6eda 100644 --- a/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpec.kt +++ b/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpec.kt @@ -45,15 +45,6 @@ abstract class FieldsSpec : DocumentSpec { this.field(path, description, example, T::class, attributes) } - inline fun ignoredField( - path: String, - description: String?, - example: T, - attributes: Map = mapOf("optional" to false, "ignored" to true), - ) { - this.field(path, description, example, T::class, attributes) - } - inline fun subsectionField( path: String, description: String?, @@ -71,6 +62,8 @@ abstract class FieldsSpec : DocumentSpec { attributes: Map, ) + abstract fun ignoredField(path: String) + abstract fun subsectionField( path: String, description: String?, diff --git a/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecBuilder.kt b/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecBuilder.kt index 5180012..715866b 100644 --- a/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecBuilder.kt +++ b/korest-docs-core/src/main/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecBuilder.kt @@ -49,6 +49,14 @@ class FieldsSpecBuilder( add(descriptor) } + override fun ignoredField( + path: String, + ) { + val descriptor = PayloadDocumentation.fieldWithPath(path).ignored() + + add(descriptor) + } + override fun subsectionField( path: String, description: String?, diff --git a/korest-docs-core/src/test/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecTest.kt b/korest-docs-core/src/test/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecTest.kt index 5552d39..6fae6ec 100644 --- a/korest-docs-core/src/test/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecTest.kt +++ b/korest-docs-core/src/test/kotlin/io/github/lcomment/korestdocs/spec/FieldsSpecTest.kt @@ -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 } } }