You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ That is the core model of the library:
46
46
- encode and decode come from the same definition
47
47
- contract changes stay visible in one place
48
48
49
-
That same authored path also covers explicit tagged unionsand recursive case trees through `Schema.union`, `Schema.unionNamed`, and `Schema.delay`.
49
+
That same authored path also covers explicit tagged unions, string-valued enums, message envelopes, and recursive case trees through `Schema.union`, `Schema.inlineUnion`, `Schema.envelope`, `Schema.stringEnum`, and `Schema.delay`.
- Add one configuration-loading guide that shows layered environment/file input, explicit defaults, startup validation, and friendly failure reporting.
49
49
- Keep the examples grounded in the existing stable DSL rather than introducing framework-specific schema systems.
50
50
51
-
-[ ]**Task 39: Improve union and enum authoring ergonomics for app contracts**
51
+
-[x]**Task 39: Improve union and enum authoring ergonomics for app contracts**
52
+
- Shipped the terminology cleanup from `case0` / `case1` to `tag` / `tagWith`, and aligned the public/docs wording around tagged unions and `TaggedCase`.
53
+
- Added `inlineUnion` / `inlineUnionNamed` for inline payload-member contracts, with readable docs plus malformed-input coverage.
54
+
- Added `stringEnum` / `stringEnumNamed` as first-class string-valued contracts, including JSON Schema `enum` export.
55
+
- Added `message`, `messageWith`, `envelope`, `envelopeNamed`, `inlineEnvelope`, and `inlineEnvelopeNamed` for common message and event contract shapes.
52
56
- Add higher-level helpers for common string-enum, message-envelope, and public API union shapes so users do not have to hand-write projector/injector code for the most common cases.
53
57
- Keep the explicit authored contract visible rather than hiding it behind reflection or attributes.
54
58
- Cover JSON, XML, YAML, KeyValue, and JSON Schema export behavior for any new helpers.
Copy file name to clipboardExpand all lines: docs/HOW_TO_EXPORT_JSON_SCHEMA.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,8 @@ If you use `Schema.missingAsNone` inside a record field, the field is removed fr
79
79
- objects with properties and required fields
80
80
- nullable option shapes
81
81
- authored tagged unions as `oneOf` object branches with `const` discriminators
82
+
- authored inline tagged unions as `oneOf` object branches with merged payload properties
83
+
- authored string enums as `"type":"string"` plus explicit `enum` values
82
84
- recursive authored schemas through local `$defs` / `$ref` when the recursion is anchored with `Schema.delay`
83
85
- mapped wrapper types as their underlying wire form
84
86
@@ -108,6 +110,10 @@ let schemaText = JsonSchema.generate statusSchema
108
110
109
111
That exported schema uses one branch per case, with a `const` discriminator for the case name.
110
112
113
+
`Schema.inlineUnion` exports the same `oneOf` structure, but merges payload properties into the same object branch as the discriminator instead of nesting them under a separate payload field.
114
+
115
+
`Schema.stringEnum` exports as a string schema with an explicit `enum` list of allowed wire values.
116
+
111
117
## Export recursive authored schemas
112
118
113
119
When recursion is authored explicitly with `Schema.delay`, `JsonSchema.generate` exports a local definition and references it from recursive branches:
Copy file name to clipboardExpand all lines: docs/HOW_TO_MODEL_A_RECURSIVE_TAGGED_UNION.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# How To Model A Recursive Tagged Union
2
2
3
-
Use `Schema.union` when the JSON/XML/YAML/KeyValue wire shape should be an explicit tagged contract, and use `Schema.delay` when one of those cases needs to recurse back to the same schema.
3
+
Use `Schema.union` when the JSON/XML/YAML/KeyValue wire shape should be an explicit tagged contract with a separate payload field. Use `Schema.inlineUnion` when payload members should sit next to the discriminator at the same level. Use `Schema.delay` when one of those tags needs to recurse back to the same schema.
4
4
5
5
This is the authored-schema path for recursive tree-like contracts. The wire contract stays explicit:
6
6
@@ -78,9 +78,11 @@ value.value.value=ok
78
78
Use these helpers:
79
79
80
80
-`tag` for a tag without payload
81
-
-`tagWith` for a tag with exactly one payload value
81
+
-`tagWith` for a tag with one payload value
82
82
-`union` for the default field names `"case"` and `"value"`
83
83
-`unionNamed` when another system expects different field names
84
+
-`inlineUnion` when payload members should be merged next to the discriminator
85
+
-`inlineUnionNamed` when that inline shape needs a custom discriminator name
84
86
85
87
If you need the exact emitted JSON, XML, YAML, or KeyValue shapes, see [Tagged Union Wire Shape Reference](TAGGED_UNION_REFERENCE.md).
0 commit comments