diff --git a/api/atproto/syncsubscribeRepos.go b/api/atproto/syncsubscribeRepos.go index 1c0f509e..4dea1661 100644 --- a/api/atproto/syncsubscribeRepos.go +++ b/api/atproto/syncsubscribeRepos.go @@ -10,8 +10,7 @@ func init() { } type SyncSubscribeRepos_Commit struct { - Blobs []util.LexLink `json:"blobs" cborgen:"blobs"` - // TODO: need to fix lexgen to make LexBytes 'omitempty'. This is currently being manually edited + Blobs []util.LexLink `json:"blobs" cborgen:"blobs"` Blocks util.LexBytes `json:"blocks,omitempty" cborgen:"blocks"` Commit util.LexLink `json:"commit" cborgen:"commit"` Ops []*SyncSubscribeRepos_RepoOp `json:"ops" cborgen:"ops"` diff --git a/api/bsky/embedrecord.go b/api/bsky/embedrecord.go index 67eaea9f..f150d7ae 100644 --- a/api/bsky/embedrecord.go +++ b/api/bsky/embedrecord.go @@ -39,6 +39,7 @@ type EmbedRecord_ViewRecord struct { Cid string `json:"cid" cborgen:"cid"` Embeds []*EmbedRecord_ViewRecord_Embeds_Elem `json:"embeds,omitempty" cborgen:"embeds,omitempty"` IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` + Labels []*comatprototypes.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` Uri string `json:"uri" cborgen:"uri"` Value *util.LexiconTypeDecoder `json:"value" cborgen:"value"` } diff --git a/lex/gen.go b/lex/gen.go index 471a8d97..e86d2b0f 100644 --- a/lex/gen.go +++ b/lex/gen.go @@ -1145,7 +1145,11 @@ func (ts *TypeSchema) writeTypeDefinition(name string, w io.Writer) error { fmt.Fprintf(w, "type %s struct {\n", name) if ts.needsType { - fmt.Fprintf(w, "\tLexiconTypeID string `json:\"$type,const=%s\" cborgen:\"$type,const=%s\"`\n", ts.id, ts.id) + var omit string + if ts.id == "com.atproto.repo.strongRef" { // TODO: hack + omit = ",omitempty" + } + fmt.Fprintf(w, "\tLexiconTypeID string `json:\"$type,const=%s%s\" cborgen:\"$type,const=%s%s\"`\n", ts.id, omit, ts.id, omit) } else { //fmt.Fprintf(w, "\tLexiconTypeID string `json:\"$type,omitempty\" cborgen:\"$type,omitempty\"`\n") } @@ -1183,7 +1187,15 @@ func (ts *TypeSchema) writeTypeDefinition(name string, w io.Writer) error { } } - fmt.Fprintf(w, "\t%s %s%s `json:\"%s%s\" cborgen:\"%s%s\"`\n", goname, ptr, tname, k, omit, k, omit) + jsonOmit, cborOmit := omit, omit + + // TODO: hard-coded hacks for now, making this type (with underlying type []byte) + // be omitempty. + if ptr == "" && tname == "util.LexBytes" { + jsonOmit = ",omitempty" + } + + fmt.Fprintf(w, "\t%s %s%s `json:\"%s%s\" cborgen:\"%s%s\"`\n", goname, ptr, tname, k, jsonOmit, k, cborOmit) return nil }); err != nil { return err