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.RouteMeta
import org.http4k.core.Method
import java.util.Locale.getDefault
fun operationId(routeMeta: RouteMeta, method: Method, description: String) =
routeMeta.operationId ?: (method.name.lowercase(getDefault()) + description
.split('/')
.joinToString("") { it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(getDefault()) else it.toString() } }
.replace('{', '_').replace('}', '_').replace('-', '_').trimEnd('_'))