com.ancientlightstudios.quarkus.kotlin.openapi.parser.ParseContext.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.parser
import com.ancientlightstudios.quarkus.kotlin.openapi.utils.SpecIssue
import com.fasterxml.jackson.databind.JsonNode
data class ParseContext(
val openApiVersion: ApiVersion,
val contextNode: JsonNode,
val contextPointer: JsonPointer,
val schemaCollector: SchemaCollector,
val contentTypeMapper: ContentTypeMapper
) {
// the root context is the first context from which everything else derived
var rootContext: ParseContext = this
private set
val contextPath: String
get() = contextPointer.path
fun contextFor(newContextNode: JsonNode, vararg segments: String) = ParseContext(
openApiVersion,
newContextNode,
contextPointer.append(*segments),
schemaCollector,
contentTypeMapper
)
.also { it.rootContext = rootContext }
fun contextFor(vararg segments: String): ParseContext {
val newContextNode = contextNode.resolvePointer(JsonPointer.fromSegments(*segments))
?: SpecIssue("Path ${this.contextPointer.append(*segments).path} not resolvable.")
return contextFor(newContextNode, *segments)
}
fun contextFor(pointer: JsonPointer): ParseContext {
val newContextNode = contextNode.resolvePointer(pointer) ?: SpecIssue("Path ${pointer.path} not resolvable.")
return ParseContext(openApiVersion, newContextNode, pointer, schemaCollector, contentTypeMapper)
.also { it.rootContext = rootContext }
}
}