-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DisplayPreferencesDtoNullabilityFixHook
A hook that modifies the type of the "customPrefs" property in "DisplayPreferencesDto" to fix a nullability issue. In the 10.7 API specification the value of the map is incorrectly labelled as not-null. This hook changes the type to the exact type emitted from the 10.8 alpha API specification.
- Loading branch information
1 parent
ea68dfb
commit b94b383
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...c/main/kotlin/org/jellyfin/openapi/hooks/model/DisplayPreferencesDtoNullabilityFixHook.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.jellyfin.openapi.hooks.model | ||
|
||
import com.squareup.kotlinpoet.typeNameOf | ||
import io.swagger.v3.oas.models.media.Schema | ||
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 "customPrefs" property in "DisplayPreferencesDto" to fix a nullability issue. | ||
* In the 10.7 API specification the value of the map is incorrectly labelled as not-null. | ||
* This hook changes the type to the exact type emitted from the 10.8 alpha API specification. | ||
*/ | ||
@OptIn(ExperimentalStdlibApi::class) | ||
class DisplayPreferencesDtoNullabilityFixHook : TypeBuilderHook { | ||
override fun onBuildType(path: TypePath, schema: Schema<*>, typeBuilder: OpenApiTypeBuilder) = when (path) { | ||
ModelTypePath("DisplayPreferencesDto", "customPrefs") -> typeNameOf<Map<String, String?>>() | ||
else -> null | ||
} | ||
} |