enumSerializers

val enumSerializers: SerializersModule

The contextual serializers writing each registered enum under the label PostgreSQL holds, rather than under the Kotlin constant's own name.

registerEnum teaches the driver that Praetor is PRAETOR in an enum column. A jsonb payload never reaches that, so the same value would read two ways depending on where it was stored. json already carries this, and so does any Json handed to resultConverter, parameterConverter or toDynamicDto - nothing here needs it added. It is exposed for the Json built elsewhere: an HTTP layer, or a jsonb column written through the driver rather than through a dynamic_dto.

val api = Json {
serializersModule = octaviusSerializersModule + db.dynamicTypes.enumSerializers
}

@Contextual on the property is what selects one; the enum itself needs no @Serializable and no serializer written by hand, whether it was named at registerEnum or found by a scan through PgEnumType.

It answers for the enums registered at the moment it is read - registration being global to the database and done at startup - so a Json built from it before startup has finished is a Json short of whatever registered after. That is the difference between it and json, which resolves per conversion and so never goes stale.

Reading it opens a session if this client has not reached the driver's registry yet, which is why it is something to take once and keep rather than to reach for per request.