The following lexicon is not accepted as valid
{
"lexicon": 1,
"id": "org.example.test",
"defs": {
"main": {
"type": "record",
"key":"tid",
"record": {
"type": "object",
"properties": {
"test":{
"type":"ref",
"ref":"#generic"
}
}
}
},
"generic": {
"type": "union",
"refs": [
"#concrete1",
"#concrete2"
],
"closed":true
},
"concrete1": {
"type": "object",
"required":["p1"],
"properties": {
"p1": {
"type": "string"
}
}
},
"concrete2": {
"type": "object",
"properties": {
"p1": {
"type": "string"
}
}
}
}
}
In the console i get the following message
invalid_literal at .defs.generic.type (expected "record", "query", "procedure", "subscription", "object", "array", "token", "bytes", "cid-link", "blob", "boolean", "integer", "string" or "unknown")
If i validate a record using this with goat it correctly validates
According to the reference implementation, this isn't valid: https://github.com/bluesky-social/atproto/blob/1e49025331c8743d1ef4057d71fbae32ffacf3c5/packages/lexicon/src/types.ts#L330
refandunioncannot be valid types in top-level definitions to avoid ambiguity