All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lancom.openapi.tools.ApiEndpoints.kt Maven / Gradle / Ivy

Go to download

This open-source project provides an OpenAPI 3.0 Parser implemented in Kotlin, utilizing immutable data classes

There is a newer version: 2.1.1
Show newest version
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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy