
commonMain.io.github.optimumcode.json.schema.internal.SchemaLoaderConfig.kt Maven / Gradle / Ivy
package io.github.optimumcode.json.schema.internal
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
internal interface SchemaLoaderConfig {
val allFactories: List
fun factories(schemaDefinition: JsonElement): List
val keywordResolver: KeyWordResolver
val referenceFactory: ReferenceFactory
}
/**
* Factory to create assertion from reference
*/
internal interface ReferenceFactory {
/**
* Tries to extract a reference from [schemaDefinition].
*
* @return [RefHolder] if [schemaDefinition] has reference. Otherwise, returns `null`
*/
fun extractRef(
schemaDefinition: JsonObject,
context: SchemaLoaderContext,
): RefHolder?
/**
* Defines whether the other schema properties should be loaded when reference is present
*/
val allowOverriding: Boolean
/**
* Defines whether the $id should be processed before resolving any references.
* Depending on that the canonical URI might change.
* Please, see
* https://json-schema.org/draft-07/json-schema-core#rfc.section.8
* https://json-schema.org/draft/2019-09/json-schema-core#rfc.section.8.2
*/
val resolveRefPriorId: Boolean
fun recursiveResolutionEnabled(schemaDefinition: JsonObject): Boolean
sealed class RefHolder {
data class Simple(
val property: String,
val refId: RefId,
) : RefHolder()
data class Recursive(
val property: String,
val refId: RefId,
) : RefHolder()
}
}
/**
* Resolver for schema draft key words
*/
internal interface KeyWordResolver {
/**
* Returns the property name that is associated with [keyword] for current schema draft
*/
fun resolve(keyword: KeyWord): String?
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy