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

io.github.nomisrev.openapi.OpenAPIContext.kt Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy