com.ancientlightstudios.quarkus.kotlin.openapi.verify.EnumVerifier.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
A Maven plugin to use the OpenAPI generator.
package com.ancientlightstudios.quarkus.kotlin.openapi.verify
import com.ancientlightstudios.quarkus.kotlin.openapi.models.openapi.ApiSpec
import com.ancientlightstudios.quarkus.kotlin.openapi.models.openapi.schema.Schema
import com.ancientlightstudios.quarkus.kotlin.openapi.models.openapi.schema.validation.EnumValidation
import com.ancientlightstudios.quarkus.kotlin.openapi.utils.SpecIssue
class EnumVerifier : Verifier {
override fun verify(apiSpec: ApiSpec) {
val enumSchemas = apiSpec.getAllSchemas()
.filterIsInstance()
.filter { it.defaultValue != null }
.filter { it.validations.any { it is EnumValidation } }
.associateWith { it.validations.filterIsInstance().first() }
enumSchemas.forEach { (schema, validation) ->
if (!validation.values.contains(schema.defaultValue)) {
SpecIssue("Default value for schema ${schema.originPath} is not a valid enum value.")
}
}
}
}