Skip to content

Codegen: emit one file per model in typed sub-packages#67

Merged
AndroidPoet merged 1 commit into
mainfrom
feat/codegen-file-per-model
Jun 22, 2026
Merged

Codegen: emit one file per model in typed sub-packages#67
AndroidPoet merged 1 commit into
mainfrom
feat/codegen-file-per-model

Conversation

@AndroidPoet

Copy link
Copy Markdown
Owner

Studied OpenAPI Generator / jOOQ layouts and moved codegen from a single SupabaseModels.kt to one file per model in typed sub-packages.

What

  • Tables → {package}.tables (one file each); Postgres enums → {package}.enums (one file each). Mirrors jOOQ.
  • Large schemas stay navigable; a column change is a one-file diff.
  • A table and an enum that share a Kotlin name (e.g. order_status) no longer collide — they're in different packages.
  • Generated header now tells users to customise via extension functions/properties in their own file (don't hand-edit generated code).

API change (pre-stable)

  • SupabaseModelGenerator.generate(spec, package) now returns List<GeneratedFile> (was a single String).
  • Removed the CLI --file flag and the Gradle fileName option (no longer one file).

Verified

  • :supabase-codegen + :supabase-codegen-gradle build green (tests + detekt + spotless); tests updated for the new layout.
  • Regenerated the chat-compose sample into generated/tables/ and compiled the 3 model files with kotlinc + the serialization plugin (serializers generated).

Generate one file per table under {package}.tables and one per Postgres enum
under {package}.enums (jOOQ-style) instead of a single SupabaseModels.kt. Keeps
large schemas navigable and yields one-file diffs per column change; a table and
an enum sharing a Kotlin name no longer collide. generate() now returns
List<GeneratedFile>; removed the CLI --file flag and the Gradle fileName option.
Generated header now points users to extension functions for customisation.

Regenerated the chat-compose sample into the new tables/ layout.
@AndroidPoet AndroidPoet merged commit a57a3a7 into main Jun 22, 2026
6 of 8 checks passed
@AndroidPoet AndroidPoet deleted the feat/codegen-file-per-model branch June 22, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant