Skip to content

Commit

Permalink
fix: kotlin schema extract request regex (#715)
Browse files Browse the repository at this point in the history
If a verb to verb request object had multiple parameters the regex would
capture the last found match. This would result in the matcher finding
something like `ages = ...` instead of `TimeRequest`

With a call like this, the regex would find `ages = listOf(1, 2, 3)` for
the `req` instead of `TimeRequest`
```kotlin
val response = context.call(TimeModuleClient::time, TimeRequest(name = req.name ?: "anonymous", ages = listOf(1, 2, 3)))
```
  • Loading branch information
wesbillman authored Dec 7, 2023
1 parent 2dae33b commit a6f9c93
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class SchemaExtractor(
)

private fun getCallMatcher(ctxVarName: String): Regex {
return """${ctxVarName}.call\((?<fn>[^)]+),(?<req>[^)]+)\(.*\)\)""".toRegex(RegexOption.IGNORE_CASE)
return """${ctxVarName}\.call\((?<fn>[^,]+),\s*(?<req>[^,]+?)\s*\(""".toRegex(RegexOption.IGNORE_CASE)
}

private fun KotlinType.toClassDescriptor(): ClassDescriptor =
Expand Down

0 comments on commit a6f9c93

Please sign in to comment.