-
Notifications
You must be signed in to change notification settings - Fork 3
fix(generator): comprehensive fixes for primitives and correctness #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
leoafarias
wants to merge
11
commits into
main
Choose a base branch
from
fix/ack-generator-primitives
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Phase 1: Extension type redesign
- Skip extension type generation for primitive schemas (String, int, double, bool, List)
- Only generate extension types for object schemas (Map<String, Object?>)
- Update ack_type.dart documentation to reflect design decision
Phase 2: Correctness fixes
- Enum fields now use Ack.enumValues<T>(T.values) instead of enumString
- Getters are nullable when !isRequired || isNullable
- Special types (DateTime, Uri, Duration) properly convert in getters
- Prevent duplicate discriminator keys in subtype schemas
- Discriminated base schemas use subtype's custom schemaName
Phase 3: Maintainability
- Use analyzer APIs (withNullability: false) instead of replaceAll('?', '')
- Centralize string escaping with jsonEncode
- Topological sort falls back to stable order on cycles (no throw)
- Gate debug file write behind ACK_GENERATOR_DEBUG=true env var
- Allow discriminator override via getter (not just fields)
Phase 4: Nested list schema-variable fix
- Ack.list(schemaRef) resolves to Map<String, Object?> at element level
- Nested lists resolve correctly (List<List<T>>)
Breaking changes:
- Primitive @AckType schemas no longer generate extension types
- Enum schemas use Ack.enumValues instead of enumString
Review improvements: - Add test for custom schemaName in discriminated subtypes - Strengthen string escaping test to validate actual escaped output - Fix test bug: remove incorrect test expecting .optional() to accept null The .optional() modifier is for object field contexts (field can be omitted from object), not for making standalone schemas accept null. Use .nullable() for accepting null values.
- Remove print() warnings in field_info.dart and generator.dart that polluted build output with non-actionable messages - Remove documentation-only tests with expect(true, isTrue) assertions that inflated test counts without testing anything
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
- Update @AckType docs to reflect that ALL schema types generate extension types - Remove redundant shouldGenerateExtensionType property (always returned true) - Fix stale comment in TypeBuilder that said primitives don't get extension types - Add test coverage for nullable object schemas skipping extension type generation - Document list element type inference limitation for chained modifiers
…duplication - Upgrade circular dependency log from info to warning for better visibility - Remove unused CircularDependencyError class (dead code) - Simplify _buildSpecialTypeGetter using Dart 3 switch expression (-14 lines)
- Fix numeric constraints (Min/Max/MultipleOf) to handle int literals by trying toIntValue() first, then toDoubleValue() - Fix nested schema references to honor custom @AckModel(schemaName:...) by passing model list to FieldBuilder for lookup - Add validation for schema variable JSON keys to throw clear errors for invalid Dart identifiers and reserved keywords - Fix safeParse() to catch exceptions from SchemaType.of() to maintain the "never throws" guarantee - Fix listExactItems() JSON Schema output to emit minItems/maxItems instead of const
Resolve conflict in comparison_constraint.dart by accepting main's DRY improvements from PR #53. The refactored toJsonSchema() method uses the new _ConstraintCategory enum and _categorize() helper for cleaner code.
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.
Summary
Ack.enumValues<T>(), nullable getters when!isRequired || isNullable, proper DateTime/Uri/Duration conversion, prevent duplicate discriminator keysTest plan
.optional()to accept null