de.lancom.openapi.tools.ApiEndpoints.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-parser Show documentation
Show all versions of openapi-parser Show documentation
This open-source project provides an OpenAPI 3.0 Parser implemented in Kotlin, utilizing immutable data classes
package de.lancom.openapi.tools
import de.lancom.openapi.entity.OpenApi
import de.lancom.openapi.entity.Operation
import de.lancom.openapi.entity.OperationType
import de.lancom.openapi.entity.Paths
import de.lancom.openapi.jackson.takeUnlessEmpty
fun OpenApi.apiEndpoints(): Map> {
return paths?.apiEndpoints() ?: emptyMap()
}
fun Paths.apiEndpoints(): Map> {
return pathItems.mapNotNull { (path, pathItem) ->
if (pathItem == null) {
null
} else {
OperationType(pathItem).takeUnlessEmpty()?.let { operations ->
path to operations
}
}
}.toMap()
}