Skip to content

Commit

Permalink
separated ServerPath.escaped into multiple implementations for each l…
Browse files Browse the repository at this point in the history
…anguage output.
  • Loading branch information
bjsvedin committed Mar 5, 2024
1 parent 2443a7d commit feecfd9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Expand Up @@ -503,4 +503,17 @@ private val SerialDescriptor.simpleSerialName: String
get() = serialName.substringBefore('<').substringAfterLast('.').removeSuffix("?")

private fun String.userTypeTokenName(): String =
this.substringAfterLast('.').replaceFirstChar { it.lowercase() }.plus("Token")
this.substringAfterLast('.').replaceFirstChar { it.lowercase() }.plus("Token")


private val ServerPath.escaped: String
get() = "/" + segments.joinToString("/") {
when (it) {
is ServerPath.Segment.Constant -> it.value
is ServerPath.Segment.Wildcard -> "\${${it.name}}"
}
} + when (after) {
ServerPath.Afterwards.None -> ""
ServerPath.Afterwards.TrailingSlash -> "/"
ServerPath.Afterwards.ChainedWildcard -> "/*"
}
Expand Up @@ -410,7 +410,8 @@ private fun arguments(documentable: Documentable, skipAuth: Boolean = false): Li
else -> TODO()
}

internal val ServerPath.escaped: String

private val ServerPath.escaped: String
get() = "/" + segments.joinToString("/") {
when (it) {
is ServerPath.Segment.Constant -> it.value
Expand Down
Expand Up @@ -437,4 +437,17 @@ private val SerialDescriptor.simpleSerialName: String
get() = serialName.substringBefore('<').substringAfterLast('.').removeSuffix("?")

private fun String.userTypeTokenName(): String =
this.substringAfterLast('.').replaceFirstChar { it.lowercase() }.plus("Token")
this.substringAfterLast('.').replaceFirstChar { it.lowercase() }.plus("Token")


private val ServerPath.escaped: String
get() = "/" + segments.joinToString("/") {
when (it) {
is ServerPath.Segment.Constant -> it.value
is ServerPath.Segment.Wildcard -> "\${${it.name}}"
}
} + when (after) {
ServerPath.Afterwards.None -> ""
ServerPath.Afterwards.TrailingSlash -> "/"
ServerPath.Afterwards.ChainedWildcard -> "/*"
}

0 comments on commit feecfd9

Please sign in to comment.