christiandeange / ozone

Kotlin Multiplatform bindings for Bluesky
MIT License
36 stars 6 forks source link

Response object with a property that is a reference to an array of unions is generated as a single union instead #5

Closed Emplexx closed 8 months ago

Emplexx commented 8 months ago

getPreferences returns an object, with a single property preferences which is a reference to app.bsky.actor.defs#preferences The definition of app.bsky.actor.defs#preferences is an array type with items of union type. However, this is the generated response object:

@Serializable
public data class GetPreferencesResponse(
  public val preferences: PreferencesUnion,
)

As you can see, the preferences field is not an array of PreferencesUnion, but a single union instead. Trying to call getPreferences from the generated XrpcBlueskyApi naturally results in an exception:

io.ktor.serialization.JsonConvertException: Illegal input: Expected class kotlinx.serialization.json.JsonObject as the serialized body of app.bsky.actor.PreferencesUnion, but had class kotlinx.serialization.json.JsonArray