Skip to content

Commit

Permalink
fix: register gson CustomTypeAdapterFactory in kotlin-client if gener…
Browse files Browse the repository at this point in the history
…ateOneOfAnyOfWrappers enabled (#20217)
  • Loading branch information
Djaler authored Dec 3, 2024
1 parent 25d780e commit 26609e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ import java.util.concurrent.atomic.AtomicLong
.registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter())
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
.registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter())
{{#generateOneOfAnyOfWrappers}}
{{#models}}
{{#model}}
{{^isEnum}}
{{^hasChildren}}
.registerTypeAdapterFactory({{modelPackage}}.{{{classname}}}.CustomTypeAdapterFactory())
{{/hasChildren}}
{{/isEnum}}
{{/model}}
{{/models}}
{{/generateOneOfAnyOfWrappers}}

@JvmStatic
val gson: Gson by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ object Serializer {
.registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter())
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
.registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiAnnotation.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiAnyOfUserOrPet.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiAnyOfUserOrPetOrArrayString.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiApiResponse.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiCategory.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiOrder.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiPet.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiTag.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiUser.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiUserOrPet.CustomTypeAdapterFactory())
.registerTypeAdapterFactory(org.openapitools.client.models.ApiUserOrPetOrArrayString.CustomTypeAdapterFactory())

@JvmStatic
val gson: Gson by lazy {
Expand Down

0 comments on commit 26609e9

Please sign in to comment.