Skip to content

Commit c631886

Browse files
authored
Fix to get regexp properly from the pattern constraint (#247)
1 parent 437d7da commit c631886

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/ConstraintResolver.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal object ConstraintResolver {
3636

3737
private fun FieldDescriptor.maybeSizeConstraint() = findConstraints(this).firstOrNull { SIZE_CONSTRAINT == it.name }
3838

39-
internal fun maybePattern(fieldDescriptor: FieldDescriptor?) = fieldDescriptor?.maybePatternConstraint()?.let { it.configuration["pattern"] as? String }
39+
internal fun maybePattern(fieldDescriptor: FieldDescriptor?) = fieldDescriptor?.maybePatternConstraint()?.let { it.configuration["regexp"] as? String }
4040

4141
private fun FieldDescriptor.maybePatternConstraint() = findConstraints(this).firstOrNull { PATTERN_CONSTRAINT == it.name }
4242

Diff for: restdocs-api-spec-jsonschema/src/test/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ class JsonSchemaFromFieldDescriptorsGeneratorTest {
650650
listOf(
651651
Constraint(
652652
"javax.validation.constraints.Pattern",
653-
mapOf("pattern" to "[a-z]")
653+
mapOf("regexp" to "[a-z]")
654654
)
655655
)
656656
)

0 commit comments

Comments
 (0)