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

de.codecentric.hikaku.converters.raml.extensions.MethodExtensions.kt Maven / Gradle / Ivy

package de.codecentric.hikaku.converters.raml.extensions

import de.codecentric.hikaku.endpoints.HeaderParameter
import de.codecentric.hikaku.endpoints.HttpMethod
import de.codecentric.hikaku.endpoints.QueryParameter
import org.raml.v2.api.model.v10.methods.Method

internal fun Method.hikakuHttpMethod() = HttpMethod.valueOf(this.method().toUpperCase())

internal fun Method.hikakuQueryParameters(): Set {
    return this.queryParameters()
            .map {
                QueryParameter(it.name(), it.required())
            }
            .toSet()
}

internal fun Method.hikakuHeaderParameters(): Set {
    return this.headers()
            .map {
                HeaderParameter(it.name(), it.required())
            }
            .toSet()
}

internal fun Method.requestMediaTypes(): Set {
    return this.body().map {
        it.name()
    }
    .toSet()
}

internal fun Method.responseMediaTypes(): Set {
    return this.responses().flatMap {response ->
        response.body().map { it.name() }
    }
            .toSet()
}

internal fun Method.isEndpointDeprecated() =
        this.annotations().any { i -> i.annotation().name() == "deprecated" }
                || checkNotNull(this.resource()).annotations().any { i -> i.annotation().name() == "deprecated" }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy