You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add x-duplicated-data-type guard to kotlinx_serialization oneOf/anyOf templates
The Gson path already uses {{^vendorExtensions.x-duplicated-data-type}} to skip
duplicate data types, but the new kotlinx_serialization path was missing this
guard. Without it, duplicate value class names would be generated if multiple
schemas resolve to the same Kotlin dataType, causing compilation errors.
{{#nonPublicApi}}internal {{/nonPublicApi}}{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}value class {{#fnToValueClassName}}{{{dataType}}}{{/fnToValueClassName}}(val value: {{{dataType}}}) : {{classname}}
110
111
112
+
{{/vendorExtensions.x-duplicated-data-type}}
111
113
{{/anyOf}}
112
114
{{/composedSchemas}}
113
115
}
@@ -121,6 +123,7 @@ import java.io.IOException
121
123
when (value) {
122
124
{{#composedSchemas}}
123
125
{{#anyOf}}
126
+
{{^vendorExtensions.x-duplicated-data-type}}
124
127
{{#isArray}}
125
128
is {{classname}}.{{#fnToValueClassName}}{{{dataType}}}{{/fnToValueClassName}} -> jsonEncoder.encodeJsonElement(jsonEncoder.json.encodeToJsonElement(value.value))
126
129
{{/isArray}}
@@ -153,6 +156,7 @@ import java.io.IOException
153
156
is {{classname}}.{{#fnToValueClassName}}{{{dataType}}}{{/fnToValueClassName}} -> jsonEncoder.encodeSerializableValue({{{dataType}}}.serializer(), value.value)
{{#nonPublicApi}}internal {{/nonPublicApi}}{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}value class {{#fnToValueClassName}}{{{dataType}}}{{/fnToValueClassName}}(val value: {{{dataType}}}) : {{classname}}
172
173
174
+
{{/vendorExtensions.x-duplicated-data-type}}
173
175
{{/oneOf}}
174
176
{{/composedSchemas}}
175
177
}
@@ -183,6 +185,7 @@ import java.io.IOException
183
185
when (value) {
184
186
{{#composedSchemas}}
185
187
{{#oneOf}}
188
+
{{^vendorExtensions.x-duplicated-data-type}}
186
189
{{#isArray}}
187
190
is {{classname}}.{{#fnToValueClassName}}{{{dataType}}}{{/fnToValueClassName}} -> jsonEncoder.encodeJsonElement(jsonEncoder.json.encodeToJsonElement(value.value))
188
191
{{/isArray}}
@@ -215,6 +218,7 @@ import java.io.IOException
215
218
is {{classname}}.{{#fnToValueClassName}}{{{dataType}}}{{/fnToValueClassName}} -> jsonEncoder.encodeSerializableValue({{{dataType}}}.serializer(), value.value)
0 commit comments