com.ancientlightstudios.quarkus.kotlin.openapi.transformer.SchemaUtils.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.transformer
import com.ancientlightstudios.quarkus.kotlin.openapi.models.openapi.schema.*
fun SchemaDefinition.getAllProperties(): List> {
val result = mutableListOf>()
if (this is ObjectSchemaDefinition) {
result.addAll(properties)
} else if (this is AllOfSchemaDefinition) {
result.addAll(schemas.map { getSchemaDefinition(it) }.flatMap { it.getAllProperties() })
}
return result
}
private fun getSchemaDefinition(schema: Schema): SchemaDefinition =
when (schema) {
is SchemaDefinition -> schema
is SchemaReference<*> -> getSchemaDefinition(schema.target)
}