Add new SyncPlayGroupUpdateHook hook

This commit is contained in:
Niels van Velzen 2020-10-01 18:51:44 +02:00
parent a2c8de23a9
commit 484d13a370
2 changed files with 23 additions and 0 deletions

View File

@ -3,11 +3,14 @@ package org.jellyfin.openapi.hooks
import org.jellyfin.openapi.hooks.api.BinaryOperationUrlHook
import org.jellyfin.openapi.hooks.model.ImageMapsHook
import org.jellyfin.openapi.hooks.model.NullableReferencesHook
import org.jellyfin.openapi.hooks.model.SyncPlayGroupUpdateHook
import org.koin.dsl.bind
import org.koin.dsl.module
val hooksModule = module {
single { ImageMapsHook() } bind TypeBuilderHook::class
single { NullableReferencesHook() } bind TypeBuilderHook::class
single { SyncPlayGroupUpdateHook() } bind TypeBuilderHook::class
single { BinaryOperationUrlHook() } bind OperationUrlHook::class
}

View File

@ -0,0 +1,20 @@
package org.jellyfin.openapi.hooks.model
import com.squareup.kotlinpoet.asTypeName
import io.swagger.v3.oas.models.media.Schema
import kotlinx.serialization.json.JsonElement
import org.jellyfin.openapi.builder.openapi.OpenApiTypeBuilder
import org.jellyfin.openapi.hooks.ModelTypePath
import org.jellyfin.openapi.hooks.TypeBuilderHook
import org.jellyfin.openapi.hooks.TypePath
/**
* A hook that modifies the type of the "data" property in "ObjectGroupUpdate". It uses the
* "JsonElement" type as it is now known it advance what actual type is used.
*/
class SyncPlayGroupUpdateHook : TypeBuilderHook {
override fun onBuildType(path: TypePath, schema: Schema<*>, typeBuilder: OpenApiTypeBuilder) = when (path) {
ModelTypePath("ObjectGroupUpdate", "data") -> JsonElement::class.asTypeName()
else -> null
}
}