From b2e4e4242c9d8d4fbdc026a80dfefa86697a5649 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sat, 24 Jul 2021 18:13:33 -0700 Subject: schema: have issued+accessed (CSLDate) actually omitempty Similar to TargetCSL, these should be pointer types so they don't get encoded as empty objects when not set. --- skate/reduce.go | 2 +- skate/reduce_test.go | 4 ++-- skate/schema.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'skate') diff --git a/skate/reduce.go b/skate/reduce.go index e2fa130..356ed25 100644 --- a/skate/reduce.go +++ b/skate/reduce.go @@ -598,7 +598,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [ Title: r.Biblio.Title, URL: r.Biblio.Url, Volume: r.Biblio.Volume, - Issued: CSLDate{ + Issued: &CSLDate{ Raw: year, }, } diff --git a/skate/reduce_test.go b/skate/reduce_test.go index 9c134f8..7cde68f 100644 --- a/skate/reduce_test.go +++ b/skate/reduce_test.go @@ -199,7 +199,7 @@ func TestMatchedRefsExtend(t *testing.T) { MatchReason: ReasonUnknown.Short(), SourceYear: "0", TargetCSL: &CSL{ - Accessed: CSLDate{}, + Accessed: nil, Author: nil, CollectionTitle: "", ContainerTitle: "", @@ -209,7 +209,7 @@ func TestMatchedRefsExtend(t *testing.T) { ISBN: "", ISSN: "", Issue: "", - Issued: CSLDate{}, + Issued: &CSLDate{}, JournalAbbreviation: "", Language: "", NumberOfPages: "", diff --git a/skate/schema.go b/skate/schema.go index 93c9680..50f52d6 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -431,7 +431,7 @@ type BiblioRef struct { // https://github.com/citation-style-language/schema, // https://navneethg.github.io/jsonschemaviewer/. This is a subset only. type CSL struct { - Accessed CSLDate `json:"accessed,omitempty"` + Accessed *CSLDate `json:"accessed,omitempty"` Author []CSLAuthor `json:"author,omitempty"` CollectionTitle string `json:"collection-title,omitempty"` ContainerTitle string `json:"container-title,omitempty"` @@ -441,7 +441,7 @@ type CSL struct { ISBN string `json:"ISBN,omitempty"` ISSN string `json:"ISSN,omitempty"` Issue string `json:"issue,omitempty"` - Issued CSLDate `json:"issued,omitempty"` + Issued *CSLDate `json:"issued,omitempty"` JournalAbbreviation string `json:"journalAbbreviation,omitempty"` Language string `json:"language,omitempty"` NumberOfPages string `json:"number-of-pages,omitempty"` -- cgit v1.2.3