Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

feat: allow inline link definitions for kinded unions #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion schemas/schema-schema.ipldsch
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,15 @@ type UnionRepresentation union {
##
## The referenced type must of course produce the RepresentationKind it's
## matched with!
type UnionRepresentation_Kinded {RepresentationKind:TypeName}
type UnionRepresentation_Kinded {RepresentationKind:KindedType}

## "KindedType" is used to allow inline link definitions within a kinded union
## as a shorthand rather than requiring all links be defined as a separate type
## before used within a kinded union.
type KindedType union {
| TypeName "string"
| TypeLink "link"
} representation kinded

## "Keyed" union representations will encode as a map, where the map has
## exactly one entry, the key string of which will be used to look up the name
Expand Down
11 changes: 10 additions & 1 deletion schemas/schema-schema.ipldsch.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,16 @@
"UnionRepresentation_Kinded": {
"kind": "map",
"keyType": "RepresentationKind",
"valueType": "TypeName"
"valueType": "KindedType"
},
"KindedType": {
"kind": "union",
"representation": {
"kinded": {
"string": "TypeName",
"link": "TypeLink"
}
}
},
"UnionRepresentation_Keyed": {
"kind": "map",
Expand Down