Skip to content

Commit d598829

Browse files
authored
feat: define 'omitempty' flag in json tag (#595)
1 parent f20b2a0 commit d598829

File tree

6 files changed

+48
-48
lines changed

6 files changed

+48
-48
lines changed

schema/agentic_message.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type AgenticResponseMeta struct {
7676

7777
type StreamMeta struct {
7878
// Index specifies the index position of this block in the final response.
79-
Index int
79+
Index int64
8080
}
8181

8282
type ContentBlock struct {
@@ -213,7 +213,7 @@ type Reasoning struct {
213213

214214
type ReasoningSummary struct {
215215
// Index specifies the index position of this summary in the final Reasoning.
216-
Index int
216+
Index int64
217217

218218
Text string
219219
}

schema/claude/content_block.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package claude
1818

1919
type AssistantGenTextExtension struct {
20-
Citations []*TextCitation `json:"citations"`
20+
Citations []*TextCitation `json:"citations,omitempty"`
2121
}
2222

2323
type TextCitation struct {
24-
Type TextCitationType `json:"type"`
24+
Type TextCitationType `json:"type,omitempty"`
2525

2626
CharLocation *CitationCharLocation `json:"char_location,omitempty"`
2727
PageLocation *CitationPageLocation `json:"page_location,omitempty"`
@@ -30,40 +30,40 @@ type TextCitation struct {
3030
}
3131

3232
type CitationCharLocation struct {
33-
CitedText string `json:"cited_text"`
33+
CitedText string `json:"cited_text,omitempty"`
3434

35-
DocumentTitle string `json:"document_title"`
36-
DocumentIndex int64 `json:"document_index"`
35+
DocumentTitle string `json:"document_title,omitempty"`
36+
DocumentIndex int64 `json:"document_index,omitempty"`
3737

38-
StartCharIndex int64 `json:"start_char_index"`
39-
EndCharIndex int64 `json:"end_char_index"`
38+
StartCharIndex int64 `json:"start_char_index,omitempty"`
39+
EndCharIndex int64 `json:"end_char_index,omitempty"`
4040
}
4141

4242
type CitationPageLocation struct {
43-
CitedText string `json:"cited_text"`
43+
CitedText string `json:"cited_text,omitempty"`
4444

45-
DocumentTitle string `json:"document_title"`
46-
DocumentIndex int64 `json:"document_index"`
45+
DocumentTitle string `json:"document_title,omitempty"`
46+
DocumentIndex int64 `json:"document_index,omitempty"`
4747

48-
StartPageNumber int64 `json:"start_page_number"`
49-
EndPageNumber int64 `json:"end_page_number"`
48+
StartPageNumber int64 `json:"start_page_number,omitempty"`
49+
EndPageNumber int64 `json:"end_page_number,omitempty"`
5050
}
5151

5252
type CitationContentBlockLocation struct {
53-
CitedText string `json:"cited_text"`
53+
CitedText string `json:"cited_text,omitempty"`
5454

55-
DocumentTitle string `json:"document_title"`
56-
DocumentIndex int64 `json:"document_index"`
55+
DocumentTitle string `json:"document_title,omitempty"`
56+
DocumentIndex int64 `json:"document_index,omitempty"`
5757

58-
StartBlockIndex int64 `json:"start_block_index"`
59-
EndBlockIndex int64 `json:"end_block_index"`
58+
StartBlockIndex int64 `json:"start_block_index,omitempty"`
59+
EndBlockIndex int64 `json:"end_block_index,omitempty"`
6060
}
6161

6262
type CitationWebSearchResultLocation struct {
63-
CitedText string `json:"cited_text"`
63+
CitedText string `json:"cited_text,omitempty"`
6464

65-
Title string `json:"title"`
66-
URL string `json:"url"`
65+
Title string `json:"title,omitempty"`
66+
URL string `json:"url,omitempty"`
6767

68-
EncryptedIndex string `json:"encrypted_index"`
68+
EncryptedIndex string `json:"encrypted_index,omitempty"`
6969
}

schema/claude/response_meta.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
package claude
1818

1919
type ResponseMetaExtension struct {
20-
ID string `json:"id"`
21-
StopReason string `json:"stop_reason"`
20+
ID string `json:"id,omitempty"`
21+
StopReason string `json:"stop_reason,omitempty"`
2222
}

schema/gemini/response_meta.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package gemini
1818

1919
type ResponseMetaExtension struct {
20-
ID string `json:"id"`
21-
FinishReason string `json:"finish_reason"`
20+
ID string `json:"id,omitempty"`
21+
FinishReason string `json:"finish_reason,omitempty"`
2222
GroundingMeta *GroundingMetadata `json:"grounding_meta,omitempty"`
2323
}
2424

schema/openai/content_block.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package openai
1818

1919
type AssistantGenTextExtension struct {
20-
Annotations []*TextAnnotation `json:"annotations"`
20+
Annotations []*TextAnnotation `json:"annotations,omitempty"`
2121
}
2222

2323
type TextAnnotation struct {
24-
Type TextAnnotationType `json:"type"`
24+
Type TextAnnotationType `json:"type,omitempty"`
2525

2626
FileCitation *TextAnnotationFileCitation `json:"file_citation,omitempty"`
2727
URLCitation *TextAnnotationURLCitation `json:"url_citation,omitempty"`
@@ -31,45 +31,45 @@ type TextAnnotation struct {
3131

3232
type TextAnnotationFileCitation struct {
3333
// The ID of the file.
34-
FileID string `json:"file_id"`
34+
FileID string `json:"file_id,omitempty"`
3535
// The filename of the file cited.
36-
Filename string `json:"filename"`
36+
Filename string `json:"filename,omitempty"`
3737

3838
// The index of the file in the list of files.
39-
Index int64 `json:"index"`
39+
Index int64 `json:"index,omitempty"`
4040
}
4141

4242
type TextAnnotationURLCitation struct {
4343
// The title of the web resource.
44-
Title string `json:"title"`
44+
Title string `json:"title,omitempty"`
4545
// The URL of the web resource.
46-
URL string `json:"url"`
46+
URL string `json:"url,omitempty"`
4747

4848
// The index of the first character of the URL citation in the message.
49-
StartIndex int64 `json:"start_index"`
49+
StartIndex int64 `json:"start_index,omitempty"`
5050
// The index of the last character of the URL citation in the message.
51-
EndIndex int64 `json:"end_index"`
51+
EndIndex int64 `json:"end_index,omitempty"`
5252
}
5353

5454
type TextAnnotationContainerFileCitation struct {
5555
// The ID of the container file.
56-
ContainerID string `json:"container_id"`
56+
ContainerID string `json:"container_id,omitempty"`
5757

5858
// The ID of the file.
59-
FileID string `json:"file_id"`
59+
FileID string `json:"file_id,omitempty"`
6060
// The filename of the container file cited.
61-
Filename string `json:"filename"`
61+
Filename string `json:"filename,omitempty"`
6262

6363
// The index of the first character of the container file citation in the message.
64-
StartIndex int64 `json:"start_index"`
64+
StartIndex int64 `json:"start_index,omitempty"`
6565
// The index of the last character of the container file citation in the message.
66-
EndIndex int64 `json:"end_index"`
66+
EndIndex int64 `json:"end_index,omitempty"`
6767
}
6868

6969
type TextAnnotationFilePath struct {
7070
// The ID of the file.
71-
FileID string `json:"file_id"`
71+
FileID string `json:"file_id,omitempty"`
7272

7373
// The index of the file in the list of files.
74-
Index int64 `json:"index"`
74+
Index int64 `json:"index,omitempty"`
7575
}

schema/openai/response_meta.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
package openai
1818

1919
type ResponseMetaExtension struct {
20-
ID string `json:"id"`
21-
Status string `json:"status"`
20+
ID string `json:"id,omitempty"`
21+
Status string `json:"status,omitempty"`
2222
Error *ResponseError `json:"error,omitempty"`
2323
IncompleteDetails *IncompleteDetails `json:"incomplete_details,omitempty"`
2424
}
2525

2626
type ResponseError struct {
27-
Code string `json:"code"`
28-
Message string `json:"message"`
27+
Code string `json:"code,omitempty"`
28+
Message string `json:"message,omitempty"`
2929
}
3030

3131
type IncompleteDetails struct {
32-
Reason string `json:"reason"`
32+
Reason string `json:"reason,omitempty"`
3333
}

0 commit comments

Comments
 (0)