Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8c1ac3f
refactor(ack)!: remove duplicate list rule names
leoafarias Dec 1, 2026
22b44ff
feat(ack)!: use one API for URI validation
leoafarias Dec 1, 2026
03f3f04
feat(ack)!: standardize built-in constraint keys
leoafarias Dec 1, 2026
134ac43
fix(ack): export SchemaOperation
leoafarias Dec 1, 2026
4329ccb
refactor(ack): keep transparent schema contexts internal
leoafarias Dec 1, 2026
697af54
feat(ack)!: share the concrete public rule annotation exports
leoafarias Dec 1, 2026
cb1bf68
docs(ack): clarify which public types support exhaustive switches
leoafarias Dec 1, 2026
db2795d
fix(generator): qualify generated model field reads
leoafarias Dec 1, 2026
7d96087
refactor(ack)!: internalize schema model rendering helpers
leoafarias Dec 1, 2026
d14c7a5
fix(generator): escape discriminator keys in emitted errors
leoafarias Dec 1, 2026
c0133ca
fix(generator): qualify class statics in constructor defaults
leoafarias Dec 1, 2026
1c09946
fix(generator)!: inherit sealed union branch naming defaults
leoafarias Dec 1, 2026
57b52ef
fix(generator): name inline JSON Schema objects in UpperCamelCase
leoafarias Dec 1, 2026
7158672
fix(generator)!: validate through class-owned schemas
leoafarias Dec 1, 2026
2c3836d
fix(generator): report invalid rule arguments at their source
leoafarias Dec 1, 2026
3c81ef9
feat(generator)!: derive Dart field names from schema-first JSON keys
leoafarias Dec 1, 2026
d2b8791
fix(generator)!: normalize union and generated model behavior
leoafarias Dec 1, 2026
d03b3fa
docs(generator): clarify reserved fields and shared builder migration
leoafarias Dec 1, 2026
5328b43
test(generator): pin updated field reads and Set construction
leoafarias Dec 1, 2026
acfb12e
test(generator): expect nested generic fields to use model-owned schemas
leoafarias Dec 1, 2026
cea8b83
docs: complete the public API migration rows
leoafarias Dec 1, 2026
322f01c
test(generator): satisfy linting in wire key assertions
leoafarias Dec 1, 2026
e7bdaae
fix(generator): recognize rules without the public base type
leoafarias Dec 1, 2026
dccc05a
test(generator): pin class-owned collection schemas
leoafarias Dec 1, 2026
1500d07
test(ack): exercise legacy aliases through their public base
leoafarias Dec 1, 2026
548826c
test(generator): match each normalized wire key assertion
leoafarias Dec 1, 2026
09df6ce
fix(generator)!: reject custom class-owned schemas in sealed unions
leoafarias Dec 1, 2026
f0f513d
fix(ack)!: align built-in constraint keys with their rule families
leoafarias Dec 1, 2026
10d95e8
fix(generator): qualify constructor defaults inherited through super …
leoafarias Dec 1, 2026
ad14c95
test(ack): cover schema rendering and context internals
leoafarias Dec 1, 2026
0c1e591
docs(ack): clarify internal schema keyword migration
leoafarias Dec 1, 2026
ee1460c
docs: group URI breaking notes under unreleased headings
leoafarias Dec 1, 2026
3979edd
docs(ack): move schema operation into error context guidance
leoafarias Dec 1, 2026
b7c9259
fix(generator)!: prevent identifier shadowing in generated models
leoafarias Dec 1, 2026
a830948
fix(generator)!: unify schema-first key tokenization
leoafarias Dec 1, 2026
ef694e4
docs(generator): correct refinement and migration guidance
leoafarias Dec 1, 2026
552fd62
test(generator): cover wire keys, field names, and union diagnostics
leoafarias Dec 1, 2026
f6c5f7b
fix(generator): resolve union schema aliases in clean builds
leoafarias Dec 1, 2026
9b26114
fix(generator): use a null-aware prefix set element
leoafarias Dec 1, 2026
e70c605
chore(example): regenerate class-first runtime helpers
leoafarias Dec 1, 2026
7e7b3a5
fix(generator): show the missing union annotation hint in builds
leoafarias Dec 1, 2026
568440b
refactor(ack)!: make constraint attachment helpers internal
leoafarias Dec 1, 2026
a3dfa01
fix(generator): report invalid discriminators on the union
leoafarias Dec 1, 2026
0d26441
fix(generator)!: express inherited case style through the public anno…
leoafarias Dec 1, 2026
2cef326
fix(ack): expose the abstract generated field schema type
leoafarias Dec 1, 2026
e67856e
fix(generator)!: normalize digits and acronyms in generated names
leoafarias Dec 1, 2026
3bd1d7a
fix(generator): preserve interpolated class-owned defaults
leoafarias Dec 1, 2026
46be36b
refactor(ack)!: restrict schema context implementations
leoafarias Dec 1, 2026
990f8f8
fix(generator)!: resolve inherited defaults in the receiving library
leoafarias Dec 1, 2026
b161685
refactor(ack)!: make transparent context construction private
leoafarias Dec 1, 2026
9f03d79
fix(ack)!: validate constraints on schema copies
leoafarias Dec 1, 2026
4f68500
fix(generator)!: fall back on invalid translated JSON Schema names
leoafarias Dec 1, 2026
69c9582
fix(ack)!: name the local time constraint string_time
leoafarias Dec 1, 2026
c20d847
fix(generator)!: validate class-owned schemas before emitting facades
leoafarias Dec 1, 2026
77b9d02
fix(generator)!: reject explicit case style on schemas and libraries
leoafarias Dec 1, 2026
9dd7f71
fix(ack): infer the lazy context parent type
leoafarias Dec 1, 2026
d3c8eaa
docs(generator): clarify class-owned schema type requirements
leoafarias Dec 1, 2026
8a84821
Merge remote-tracking branch 'origin/main' into release-readiness/e-p…
leoafarias Dec 1, 2026
5ba914a
Merge remote-tracking branch 'origin/release-readiness/e-public-api' …
leoafarias Dec 1, 2026
a25ab7d
Merge origin/main (E #272 squash) into release-readiness/c-generator
leoafarias Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions docs/core-concepts/typesafe-schemas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,32 @@ Generation also rejects nullable roots, `Ack.any()` and `Ack.map()` roots,
`Ack.anyOf()`, bare `Ack.instance<T>()`, anonymous inline object fields,
unresolved dynamic schema factories, and cross-library union branches.

Schema-first JSON keys keep their spelling on the wire. Fields, discriminator
getters, and inline JSON Schema model name segments use the same word boundaries.
The generator splits at punctuation, spaces, and other characters outside
ASCII letters and digits. It also starts a word at an uppercase letter after
a lowercase letter or digit, as in `ipv4Address` and `sha256Hash`, and before
a capitalized word following an acronym, as in `HTTPServer` and `URLIsValid`.
A plural acronym such as `URLs` stays together.

Each word is lowercased, then capitalized where required by the target name.
Fields and discriminator getters leave the first word lowercase. Type name
segments capitalize it too. For example, `UserID`, `userID`, and `user_id`
all become `userId` as a field and `UserId` as a type name segment. `URLs`
becomes `urls` or `Urls`, and `address_2` becomes `address2` or `Address2`.
Generation rejects keys containing non-ASCII letters, such as `café` and
`já_ok`, as well as empty names, field names that start with a digit, Dart
reserved words, and keys that produce the same Dart member. Use a class-first
model with `@AckKey` to keep a key and choose its Dart field name.

Field and discriminator names also cannot shadow identifiers used by the
generated class. This includes `bool`, `double`, `dynamic`, `int`, `num`,
`override`, `identical`, `deepEquals`, `deepHashCode`,
`deepUnmodifiableCopy`, and `deepUnmodifiableJsonMap`. Generation also checks
the schema declaration name, the Ack import prefix, and names and import
prefixes used in field types. Use a class-first model with `@AckKey` to keep
the wire key and choose a different Dart field name.

### Schema-first unions

Each branch must be a named `@Schemable()` object schema in the same library:
Expand Down Expand Up @@ -546,8 +572,27 @@ static schema; use `Object?` for an open JSON value.
Automatic `List<T>` and `Set<T>` inference also requires non-nullable element
types because `Ack.list` has no nullable-item contract.

The generated parse and encode helpers, including `toJson()` and
`safeToJson()`, validate with a class's static `schema` when it declares one.
Nested class-first fields also use that schema. The declaration must be a
non-nullable `AckSchema` with the model as its runtime type and a boundary
type assignable to `Map<String, Object?>`.
Use `ModelSchema.schema` as the raw generated schema when declaring
`Model.schema` with refinements.

### Class-first unions

The sealed base and its branches may expose a static `schema` only as a
read-only alias of their generated facade's `schema`, such as
`static final schema = PetSchema.schema;`. Apply custom validation to the
union schema where you use it, or use a non-union model for a class-owned
schema with refinements.

Every branch inherits the sealed base’s `caseStyle` by default, including
branches with `@Schemable(discriminatorValue: ...)`. Set a branch’s own
`caseStyle` to override the base. Use `AckCaseStyle.none` to preserve the
branch’s Dart field names.

Annotate a sealed base with a discriminator key. Concrete branches in the same
library are included automatically, and inherited constructor fields may use
super parameters:
Expand Down Expand Up @@ -656,6 +701,19 @@ declare the same model name. Deferred imports are unsupported.
Automatic recursive class-first schemas are not yet defined. For self or
mutually recursive contracts, use schema-first named `Ack.lazy` schemas.

### Using Ack models inside json_serializable classes

When a `@JsonSerializable()` class holds an Ack model, specify the converters
on that field. For an Ack class with an `AccountSchema` facade, use

```dart
@JsonKey(fromJson: AccountSchema.fromJson, toJson: AccountSchema.encode)
final Account account;
```

Use `JsonKey` from `package:json_annotation/json_annotation.dart` on the
container field.

## Which direction should you choose?

Put `@Schemable()` on a top-level schema when you want to design the boundary
Expand Down
23 changes: 23 additions & 0 deletions docs/getting-started/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ This guide summarizes **what exists in Ack today**, **what changed in 1.7 and 2.

---

## Beta.3 to 2.0: generated models

| Affected code | Changed in | Migration |
| --- | --- | --- |
| A custom static `schema` on a class-first sealed union base or branch | `2.0.0` | Expose the generated facade's `schema` directly. Apply custom validation at the union level or use a non-union model. |
| Schema-first keys that shadow a generated reference, such as `override` or `identical` | `2.0.0` | Use a class-first model with `@AckKey` to preserve the wire key and give the Dart field a different name. |
| Schema-first fields, discriminators, and inline JSON Schema model names | `2.0.0` | Regenerate and update Dart callers. Digits before uppercase letters and acronym boundaries affect names such as `ipv4Address` and `urlIsValid`. Inline model segments normalize acronyms, for example `UserID` → `UserId`. Use a class-first model with `@AckKey` for keys containing non-ASCII letters, keys mapping to a reserved word such as `default`, and collisions. |
| Implicit field style on an annotated branch of a styled sealed class | `2.0.0` | Regenerate to inherit the base’s style. Use `caseStyle: AckCaseStyle.none` on the branch to retain Dart names on the wire. |
| Code that reads `Schemable.caseStyle` as non-null | `2.0.0` | Handle a null style as unspecified. Use `annotation.caseStyle ?? AckCaseStyle.none` when you need the standalone default. |
| `caseStyle: AckCaseStyle.none` on a top-level schema or library annotation | `2.0.0` | Remove the class-only option from the annotation. |
| A super parameter whose inherited default references a declaration you cannot access | `2.0.0` | Import the declaration used in the default, or give the super parameter an explicit default. |
| JSON Schema properties that cannot become distinct Dart fields, such as `@id` and `id` | `2.0.0` | Automatic generation uses a validated value model. Read the original keys from `model.value`, or define a class-first model with `@AckKey` for typed fields. |
| A JSON Schema property whose wire spelling matches its model name, such as `Model` | `2.0.0` | Regenerate and use the typed field, such as `model.model`, when the derived Dart name is valid. |
| Class-owned schema refinements | `2.0.0` | Generated helpers and nested fields now enforce them. Compose `ModelSchema.schema` explicitly when you need the raw generated rules. |
| A nullable class-owned `schema` or one with a boundary wider than a JSON map | `2.0.0` | Declare a non-nullable `AckSchema<Map<String, Object?>, Model>`. A narrower boundary type is also valid. Use `ModelSchema.schema` as the base for class-owned refinements. |
| Schema-first fields using snake_case or another wire spelling | `2.0.0` | Regenerate and use the lowerCamelCase Dart names in field accesses, constructors and `copyWith`. JSON keys keep their original spelling. |
| The direct `ackModelBuilder` factory | `2.0.0` | Use the shared `ack_generator:ack_generator` builder with source_gen’s combining builder. |
| Generated `Set<T>` fields that previously accepted duplicate JSON items | `2.0.0` | Remove duplicates or use `List<T>` when duplicates must be accepted. Exported schemas now include `uniqueItems: true` for these fields. |

## Migrating to `Is…`/`Has…` rule annotations

Ack 2.0 uses top-level rule annotations. `Is…` names what a value is; `Has…` names a bound or property it
Expand Down Expand Up @@ -122,6 +141,10 @@ Ack is organized into five coordinated packages that share one version number an
| `@AckField(description: ...)` | `2.0.0` | `/// @description ...` doc tag |
| `@JsonConverter()` on `@Schemable` classes/fields | `1.7.0` (rejected) | Declare `static final schema = ...` on the type or register one in `@Schemable(schemas: [...])` |

Schema-first union discriminator getters use the same lowerCamelCase naming as
other fields. A class-first union emits one discriminator wire key, even when
a branch field uses a different case style.

### Validation Annotations

The top-level 1.x validation and presence classes were removed in `2.0.0`.
Expand Down
65 changes: 32 additions & 33 deletions example/lib/additional_properties_example.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading