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
{{ message }}
Repository navigation
Commit b82ce07
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codegen-kotlin): expose field.string @dbColumnType:jsonb as a parsed JSON value in REST payloads (#98)
The `field.string @dbColumnType=jsonb` open JSON bag had its physical column
emitted as JSONB but was typed `String` everywhere, forcing REST clients to
double-encode (`"{\"k\":\"v\"}"` instead of `{"k":"v"}`). Per the maintainer
decision on #98, expose the bag at the serialization/REST payload boundary as a
parsed JSON value, uniformly (matching TS `z.unknown()` #97, Python `Any` #99).
Two layers, treated differently:
- Persistence (unchanged): the Exposed column stays the identity-codec
`jsonb(name, { it }, { it })` and the entity data-class property stays
`String` — the JDBC driver returns jsonb as raw text. `KotlinTypeMapper.kotlinTypeName`
/ `exposedColumnSpec` are untouched (existing `KotlinTypeMapperTest` stays green).
- REST payload (fixed): add `KotlinTypeMapper.payloadTypeName` — identical to
`kotlinTypeName` except the jsonb open bag maps to kotlinx `JsonElement` (the
`@Serializable` payload substrate this port already uses). `KotlinPayloadGenerator`
now resolves field types through it; the lenient->strict extract mapper bridges
`String -> JsonElement` via `Json.parseToJsonElement`; api-docs documents the
payload field as the parsed value it actually emits.
The type mapper is shared between persistence and the payload surface, so the
split is made by a dedicated `payloadTypeName` path keyed on the new
`isJsonbOpenBag` predicate (single source of truth for payload + extractor).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuZWKnWzYGVnESijL7uuky
Copy file name to clipboardExpand all lines: server/java/codegen-kotlin/src/main/kotlin/com/metaobjects/generator/kotlin/apidocs/KotlinApiModelBuilder.kt
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -381,18 +381,26 @@ class KotlinApiModelBuilder {
0 commit comments