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

com.ancientlightstudios.quarkus.kotlin.openapi.transformer.SchemaUtils.kt Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy