Skip to content

Add declarative model JSON mapping and configurable generated output - #29

Closed
fxsoulmate wants to merge 7 commits into
helightdev:mainfrom
fxsoulmate:codex/declarative-map-models
Closed

fxsoulmate wants to merge 7 commits into
helightdev:mainfrom
fxsoulmate:codex/declarative-map-models

Conversation

@fxsoulmate

Copy link
Copy Markdown

Problem

Applications with backend JSON aliases, nullable defaults, mixed boolean/integer flags, and strict nested error handling currently need a separate mapping helper around generated DOGs structures. Generated converter files also stay beside model sources, which makes it difficult to keep generated code in one directory.

Change

  • Add an opt-in DogModelCodec and declarative annotations for aliases, fixed values, field/list conversions, whole-map reads, and canonical output keys. It reuses generated structures and leaves native DogEngine.fromNative behavior unchanged.
  • Let DefaultValue(onNull: true) cover explicit null input while preserving the existing missing-only default.
  • Add output_directory to the descriptor, binding, and reactor builders. With generated, lib/city/city_model.dart writes to lib/generated/city/city_model.conv.g.dart and the registry to lib/generated/dogs.g.dart. Default output paths remain unchanged.

Validation

  • 31 new core and generator tests passed in an isolated Dart harness with coherent test dependencies.
  • Exercised the generator against a Flutter app with 43 generated converters and a generated registry under lib/generated.
  • The consuming app's 153 Flutter tests pass, including 48 model JSON contract fixtures; dart analyze reports no issues.

@helightdev helightdev self-assigned this Oct 15, 2026
fxsoulmate and others added 5 commits October 15, 2026 23:01
Expose jsonStringify, jsonFlagInt, and jsonInteger as the primary
converter functions for field annotations; keep JsonConversions as aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop the short-lived top-level jsonStringify helpers so field
annotations use JsonConversions.stringify and peers instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
Field annotations take a fromJson-style map factory, use the generated
field name by default, and allow an optional custom key (aliases apply
when no key is set).

Co-authored-by: Cursor <cursoragent@cursor.com>
Factory constructor tear-offs are not retained; use top-level or static
parse helpers with JsonParser and JsonListParser.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace separate alias/convert/parser/read annotations with one JsonKey that carries aliases, name, convert, each, parse, read, and value.

Co-authored-by: Cursor <cursoragent@cursor.com>
@fxsoulmate

Copy link
Copy Markdown
Author

Closing upstream PR. Declarative model JSON mapping will live only on the fxsoulmate/dogs fork.

@fxsoulmate fxsoulmate closed this Oct 15, 2026
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.

2 participants