From c6318869e0846e29ff599594103ba1d0834b1177 Mon Sep 17 00:00:00 2001 From: Ki-Eun Shin Date: Mon, 25 Sep 2023 21:00:21 +0900 Subject: [PATCH] Fix to get regexp properly from the pattern constraint (#247) --- .../epages/restdocs/apispec/jsonschema/ConstraintResolver.kt | 2 +- .../jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/ConstraintResolver.kt b/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/ConstraintResolver.kt index e2f7d1e..982ab01 100644 --- a/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/ConstraintResolver.kt +++ b/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/ConstraintResolver.kt @@ -36,7 +36,7 @@ internal object ConstraintResolver { private fun FieldDescriptor.maybeSizeConstraint() = findConstraints(this).firstOrNull { SIZE_CONSTRAINT == it.name } - internal fun maybePattern(fieldDescriptor: FieldDescriptor?) = fieldDescriptor?.maybePatternConstraint()?.let { it.configuration["pattern"] as? String } + internal fun maybePattern(fieldDescriptor: FieldDescriptor?) = fieldDescriptor?.maybePatternConstraint()?.let { it.configuration["regexp"] as? String } private fun FieldDescriptor.maybePatternConstraint() = findConstraints(this).firstOrNull { PATTERN_CONSTRAINT == it.name } diff --git a/restdocs-api-spec-jsonschema/src/test/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt b/restdocs-api-spec-jsonschema/src/test/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt index dee7210..a9ed3b1 100644 --- a/restdocs-api-spec-jsonschema/src/test/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt +++ b/restdocs-api-spec-jsonschema/src/test/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt @@ -650,7 +650,7 @@ class JsonSchemaFromFieldDescriptorsGeneratorTest { listOf( Constraint( "javax.validation.constraints.Pattern", - mapOf("pattern" to "[a-z]") + mapOf("regexp" to "[a-z]") ) ) )