io.github.nomisrev.openapi.OpenAPIContext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-kt-generator Show documentation
Show all versions of openapi-kt-generator Show documentation
Module to generate Kotlin code from OpenAPI specifications using KotlinPoet
package io.github.nomisrev.openapi
import com.squareup.kotlinpoet.FileSpec
import java.util.concurrent.atomic.AtomicReference
interface OpenAPIContext : Naming, APIInterceptor {
val `package`: String
fun addAdditionalFileSpec(fileSpec: FileSpec)
fun additionalFiles(): List
}
fun OpenAPIContext(
`package`: String,
interceptor: APIInterceptor = APIInterceptor.openAIStreaming(`package`)
): OpenAPIContext =
object : OpenAPIContext, Naming by Naming(`package`), APIInterceptor by interceptor {
override val `package`: String = `package`
private val files = AtomicReference>(emptyList())
override fun additionalFiles(): List = files.get()
override fun addAdditionalFileSpec(fileSpec: FileSpec) {
files.updateAndGet { it + fileSpec }
}
}