Repository navigation
Add declarative model JSON mapping and configurable generated output - #29
Closed
fxsoulmate wants to merge 7 commits into
Closed
fxsoulmate wants to merge 7 commits into
fxsoulmate wants to merge 7 commits into
Conversation
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>
Author
|
Closing upstream PR. Declarative model JSON mapping will live only on the fxsoulmate/dogs fork. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
DogModelCodecand declarative annotations for aliases, fixed values, field/list conversions, whole-map reads, and canonical output keys. It reuses generated structures and leaves nativeDogEngine.fromNativebehavior unchanged.DefaultValue(onNull: true)cover explicit null input while preserving the existing missing-only default.output_directoryto the descriptor, binding, and reactor builders. Withgenerated,lib/city/city_model.dartwrites tolib/generated/city/city_model.conv.g.dartand the registry tolib/generated/dogs.g.dart. Default output paths remain unchanged.Validation
lib/generated.dart analyzereports no issues.