From 50b5ca03c6082cc157d14044a2f02e2d767f2889 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Mon, 22 Mar 2021 02:44:44 +0100 Subject: [PATCH] Fix schema validator for parameters --- src/test/kotlin/integration/steps/then/schema.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/integration/steps/then/schema.kt b/src/test/kotlin/integration/steps/then/schema.kt index 0168321..a3df36e 100644 --- a/src/test/kotlin/integration/steps/then/schema.kt +++ b/src/test/kotlin/integration/steps/then/schema.kt @@ -75,10 +75,15 @@ fun TestApplicationResponse.`And the schema parameters must be valid`() { /* Validate Request URL */ this.apply { Url(call.request.uri).parameters.forEach { parameter: String, values: List -> - getParametersIn(api.context, "query") + val schema = getParametersIn(api.context, "query") ?.firstOrNull { it.name == parameter }?.schema - ?.validate(api, TextNode(values.first())) ?: error("""No parameter found ($parameter) for "$this $uri".""") + + if (schema.type == "array") { + schema.validate(api, ObjectMapper().valueToTree(values)) + } else { + schema.validate(api, TextNode(values.first())) + } } } }