Skip to content

Conversation

@leoafarias
Copy link
Collaborator

Summary

  • Primitives handling: Skip extension type generation for primitive schemas (String, int, double, bool, List) - only generate for object schemas
  • Correctness fixes: Enum fields use Ack.enumValues<T>(), nullable getters when !isRequired || isNullable, proper DateTime/Uri/Duration conversion, prevent duplicate discriminator keys
  • Maintainability: Use analyzer APIs instead of string manipulation, centralize escaping with jsonEncode, topological sort fallback on cycles
  • Cleanup: Remove print statements polluting build output, remove tautological tests

Test plan

  • Existing tests pass
  • Added tests for custom schemaName in discriminated subtypes
  • Added tests for string escaping validation
  • Fixed incorrect test expecting .optional() to accept null

claude and others added 3 commits December 20, 2025 22:46
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
@docs-page
Copy link

docs-page bot commented Dec 22, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/ack~50

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants