diff --git a/web/src/testFixtures/kotlin/web/helper/FieldDescription.kt b/web/src/testFixtures/kotlin/web/helper/FieldDescription.kt index e46669102..06e4066da 100644 --- a/web/src/testFixtures/kotlin/web/helper/FieldDescription.kt +++ b/web/src/testFixtures/kotlin/web/helper/FieldDescription.kt @@ -3,4 +3,5 @@ package web.helper class FieldDescription( val path: String, val description: String, + val optional: Boolean = false, ) \ No newline at end of file diff --git a/web/src/testFixtures/kotlin/web/helper/PayloadDocumentationExtension.kt b/web/src/testFixtures/kotlin/web/helper/PayloadDocumentationExtension.kt index 4e45c4a6e..873b3f415 100644 --- a/web/src/testFixtures/kotlin/web/helper/PayloadDocumentationExtension.kt +++ b/web/src/testFixtures/kotlin/web/helper/PayloadDocumentationExtension.kt @@ -29,26 +29,50 @@ fun FieldDescriptor.fieldWithNull(description: String): FieldDescriptor { } fun FieldDescription.asObject(): FieldDescriptor { - return PayloadDocumentation.fieldWithPath(this.path).fieldWithObject(this.description) + val descriptor = PayloadDocumentation.fieldWithPath(this.path).fieldWithObject(this.description) + if (this.optional) { + return descriptor.optional() + } + return descriptor } fun FieldDescription.asArray(): FieldDescriptor { - return PayloadDocumentation.fieldWithPath(this.path).fieldWithArray(this.description) + val descriptor = PayloadDocumentation.fieldWithPath(this.path).fieldWithArray(this.description) + if (this.optional) { + return descriptor.optional() + } + return descriptor } fun FieldDescription.asString(): FieldDescriptor { - return PayloadDocumentation.fieldWithPath(this.path).fieldWithString(this.description) + val descriptor = PayloadDocumentation.fieldWithPath(this.path).fieldWithString(this.description) + if (this.optional) { + return descriptor.optional() + } + return descriptor } fun FieldDescription.asNumber(): FieldDescriptor { - return PayloadDocumentation.fieldWithPath(this.path).fieldWithNumber(this.description) + val descriptor = PayloadDocumentation.fieldWithPath(this.path).fieldWithNumber(this.description) + if (this.optional) { + return descriptor.optional() + } + return descriptor } fun FieldDescription.asBoolean(): FieldDescriptor { - return PayloadDocumentation.fieldWithPath(this.path).fieldWithBoolean(this.description) + val descriptor = PayloadDocumentation.fieldWithPath(this.path).fieldWithBoolean(this.description) + if (this.optional) { + return descriptor.optional() + } + return descriptor } fun FieldDescription.asNull(): FieldDescriptor { - return PayloadDocumentation.fieldWithPath(this.path).fieldWithNull(this.description) + val descriptor = PayloadDocumentation.fieldWithPath(this.path).fieldWithNull(this.description) + if (this.optional) { + return descriptor.optional() + } + return descriptor } class PayloadDocumentationExtension \ No newline at end of file