org.http4k.contract.openapi.ext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-contract Show documentation
Show all versions of http4k-contract Show documentation
http4k typesafe HTTP contracts and OpenApi support
package org.http4k.contract.openapi
import org.http4k.contract.ContractRoute
import org.http4k.contract.PathSegments
import java.util.Locale.getDefault
fun ContractRoute.operationId(contractRoot: PathSegments) =
meta.operationId ?: (method.name.lowercase(getDefault()) + describeFor(contractRoot)
.split('/')
.joinToString("") { it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(getDefault()) else it.toString() } }
.replace('{', '_').replace('}', '_').trimEnd('_'))