From dfa57df1a47f2719dd599163551d6957d7437cbf Mon Sep 17 00:00:00 2001 From: tdakkota Date: Thu, 2 May 2024 16:06:27 +0300 Subject: [PATCH 1/3] fix(gen): encode discriminator field only once --- gen/_template/json/encoders_struct.tmpl | 41 ++++++++++++++----------- gen/_template/json/encoders_sum.tmpl | 8 ++++- gen/ir/json.go | 31 +++++++++++++++---- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/gen/_template/json/encoders_struct.tmpl b/gen/_template/json/encoders_struct.tmpl index 995f5470c..fa2fd1d04 100644 --- a/gen/_template/json/encoders_struct.tmpl +++ b/gen/_template/json/encoders_struct.tmpl @@ -1,11 +1,31 @@ {{- define "json/encode_struct_fields" }} -{{- /*gotype: github.com/ogen-go/ogen/gen/ir.JSONFields*/ -}} - {{- range $i, $f := $ }} +{{- /*gotype: github.com/ogen-go/ogen/gen/ir.JSON*/ -}} + {{- $fields := $.Fields }} + {{- $additional := $.AdditionalProps }} + {{- $pattern := $.PatternProps }} + {{- $sum := $.SumProps }} + + {{- range $i, $f := $fields }} { {{- $elem := field_elem $f }} {{- template "json/enc" $elem }} } {{- end }} + {{- if $additional }} + for k, elem := range s.{{ $additional.Name }} { + e.FieldStart(k) + {{ template "json/enc" map_elem $additional.Type.Item }} + } + {{- end }} + {{- range $p := $pattern }} + for k, elem := range s.{{ $p.Name }} { + e.FieldStart(k) + {{ template "json/enc" map_elem $p.Type.Item }} + } + {{- end }} + {{- range $s := $sum }} + s.{{ $s.Name }}.encodeFields(e) + {{- end }} {{- end }} {{- define "json/encoders_struct" }} @@ -67,22 +87,7 @@ func (s *{{ $.Name }}) Decode(d *jx.Decoder) error { {{- else }} // encodeFields encodes fields. func (s {{ $.ReadOnlyReceiver }}) encodeFields(e *jx.Encoder) { - {{- template "json/encode_struct_fields" $fields }} - {{- if $additional }} - for k, elem := range s.{{ $additional.Name }} { - e.FieldStart(k) - {{ template "json/enc" map_elem $additional.Type.Item }} - } - {{- end }} - {{- range $p := $pattern }} - for k, elem := range s.{{ $p.Name }} { - e.FieldStart(k) - {{ template "json/enc" map_elem $p.Type.Item }} - } - {{- end }} - {{- range $s := $sum }} - s.{{ $s.Name }}.encodeFields(e) - {{- end }} + {{- template "json/encode_struct_fields" $.JSON }} } var jsonFieldsNameOf{{ $.Name }} = [{{ len $fields }}]string{ diff --git a/gen/_template/json/encoders_sum.tmpl b/gen/_template/json/encoders_sum.tmpl index 22c031286..b80f674bf 100644 --- a/gen/_template/json/encoders_sum.tmpl +++ b/gen/_template/json/encoders_sum.tmpl @@ -24,7 +24,13 @@ func (s {{ $.ReadOnlyReceiver }}) encodeFields(e *jx.Encoder) { case {{ $m.Type.Name }}{{ $.Name }}: e.FieldStart({{ quote $.SumSpec.Discriminator }}) e.Str({{ quote $m.Key }}) - s.{{ $m.Type.Name }}.encodeFields(e) + {{- $j := $m.Type.JSON.Except $.SumSpec.Discriminator }} + {{- if $j.AnyFields }} + { + s := s.{{ $m.Type.Name }} + {{- template "json/encode_struct_fields" $j }} + } + {{- end }} {{- end }} } {{- else if $d.Fields }} diff --git a/gen/ir/json.go b/gen/ir/json.go index d6236f4bf..8b46d5b7e 100644 --- a/gen/ir/json.go +++ b/gen/ir/json.go @@ -20,16 +20,35 @@ func (t *Type) JSON() JSON { // JSON specifies json encoding and decoding for Type. type JSON struct { - t *Type + t *Type + except []string } -type JSONFields []*Field +// AnyFields whether if type has any fields to encode. +func (j JSON) AnyFields() bool { + for _, f := range j.t.Fields { + if f.Inline != InlineNone { + return true + } -// NotEmpty whether field slice is not empty. -func (j JSONFields) NotEmpty() bool { - return len(j) != 0 + t := f.Tag.JSON + if t != "" && !slices.Contains(j.except, t) { + return true + } + } + return false } +// Except return JSON with filter by given properties. +func (j JSON) Except(set ...string) JSON { + return JSON{ + t: j.t, + except: set, + } +} + +type JSONFields []*Field + // FirstRequiredIndex returns first required field index. // // Or -1 if there is no required fields. @@ -70,7 +89,7 @@ func (j JSONFields) RequiredMask() []uint8 { // Fields return all fields of Type that should be encoded via json. func (j JSON) Fields() (fields JSONFields) { for _, f := range j.t.Fields { - if f.Tag.JSON == "" { + if t := f.Tag.JSON; t == "" || slices.Contains(j.except, t) { continue } fields = append(fields, f) From 3599ea18bd761851a3994202a22f3445407fb699 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Thu, 2 May 2024 16:39:59 +0300 Subject: [PATCH 2/3] test(integration): ensure objects does not contain duplicate properties --- internal/integration/json_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/integration/json_test.go b/internal/integration/json_test.go index 221b4a048..ed52de314 100644 --- a/internal/integration/json_test.go +++ b/internal/integration/json_test.go @@ -4,6 +4,7 @@ import ( std "encoding/json" "fmt" "strconv" + "strings" "testing" "github.com/go-faster/jx" @@ -49,6 +50,31 @@ func testEncode(t *testing.T, encoder json.Marshaler, expected string) { } require.True(t, std.Valid(e.Bytes()), string(e.Bytes())) require.JSONEq(t, expected, string(e.Bytes()), "encoding result mismatch") + require.NoError(t, validProperties(jx.DecodeBytes(e.Bytes()), []string{"$"})) +} + +func validProperties(d *jx.Decoder, path []string) error { + if tt := d.Next(); tt != jx.Object { + return d.Skip() + } + + m := map[string]struct{}{} + return d.Obj(func(d *jx.Decoder, key string) error { + path = append(path, key) + defer func() { + path = path[:len(path)-1] + }() + + if _, ok := m[key]; ok { + return fmt.Errorf("duplicate field %q (at %q)", key, strings.Join(path, ".")) + } + m[key] = struct{}{} + + if err := validProperties(d, path); err != nil { + return err + } + return nil + }) } func TestJSONGenerics(t *testing.T) { From b1ddda2728d324623cdccd26c66cee1e22e983bd Mon Sep 17 00:00:00 2001 From: tdakkota Date: Thu, 2 May 2024 16:40:11 +0300 Subject: [PATCH 3/3] chore: commit generated files --- examples/ex_gotd/oas_json_gen.go | 1612 ++++++++++++++++- examples/ex_telegram/oas_json_gen.go | 1598 +++++++++++++++- .../integration/sample_api/oas_json_gen.go | 97 +- .../integration/sample_api_nc/oas_json_gen.go | 97 +- .../sample_api_no_otel/oas_json_gen.go | 97 +- .../integration/sample_api_ns/oas_json_gen.go | 97 +- .../sample_api_nsnc/oas_json_gen.go | 97 +- 7 files changed, 3559 insertions(+), 136 deletions(-) diff --git a/examples/ex_gotd/oas_json_gen.go b/examples/ex_gotd/oas_json_gen.go index 706d0d62c..93ffeb5bf 100644 --- a/examples/ex_gotd/oas_json_gen.go +++ b/examples/ex_gotd/oas_json_gen.go @@ -1939,31 +1939,49 @@ func (s BotCommandScope) encodeFields(e *jx.Encoder) { case BotCommandScopeAllChatAdministratorsBotCommandScope: e.FieldStart("type") e.Str("all_chat_administrators") - s.BotCommandScopeAllChatAdministrators.encodeFields(e) case BotCommandScopeAllGroupChatsBotCommandScope: e.FieldStart("type") e.Str("all_group_chats") - s.BotCommandScopeAllGroupChats.encodeFields(e) case BotCommandScopeAllPrivateChatsBotCommandScope: e.FieldStart("type") e.Str("all_private_chats") - s.BotCommandScopeAllPrivateChats.encodeFields(e) case BotCommandScopeChatBotCommandScope: e.FieldStart("type") e.Str("chat") - s.BotCommandScopeChat.encodeFields(e) + { + s := s.BotCommandScopeChat + { + e.FieldStart("chat_id") + s.ChatID.Encode(e) + } + } case BotCommandScopeChatAdministratorsBotCommandScope: e.FieldStart("type") e.Str("chat_administrators") - s.BotCommandScopeChatAdministrators.encodeFields(e) + { + s := s.BotCommandScopeChatAdministrators + { + e.FieldStart("chat_id") + s.ChatID.Encode(e) + } + } case BotCommandScopeChatMemberBotCommandScope: e.FieldStart("type") e.Str("chat_member") - s.BotCommandScopeChatMember.encodeFields(e) + { + s := s.BotCommandScopeChatMember + { + e.FieldStart("chat_id") + s.ChatID.Encode(e) + } + { + e.FieldStart("user_id") + e.Int64(s.UserID) + } + } case BotCommandScopeDefaultBotCommandScope: e.FieldStart("type") e.Str("default") - s.BotCommandScopeDefault.encodeFields(e) } } @@ -4272,27 +4290,177 @@ func (s ChatMember) encodeFields(e *jx.Encoder) { case ChatMemberAdministratorChatMember: e.FieldStart("status") e.Str("ChatMemberAdministrator") - s.ChatMemberAdministrator.encodeFields(e) + { + s := s.ChatMemberAdministrator + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("can_be_edited") + e.Bool(s.CanBeEdited) + } + { + e.FieldStart("is_anonymous") + e.Bool(s.IsAnonymous) + } + { + e.FieldStart("can_manage_chat") + e.Bool(s.CanManageChat) + } + { + e.FieldStart("can_delete_messages") + e.Bool(s.CanDeleteMessages) + } + { + e.FieldStart("can_manage_video_chats") + e.Bool(s.CanManageVideoChats) + } + { + e.FieldStart("can_restrict_members") + e.Bool(s.CanRestrictMembers) + } + { + e.FieldStart("can_promote_members") + e.Bool(s.CanPromoteMembers) + } + { + e.FieldStart("can_change_info") + e.Bool(s.CanChangeInfo) + } + { + e.FieldStart("can_invite_users") + e.Bool(s.CanInviteUsers) + } + { + if s.CanPostMessages.Set { + e.FieldStart("can_post_messages") + s.CanPostMessages.Encode(e) + } + } + { + if s.CanEditMessages.Set { + e.FieldStart("can_edit_messages") + s.CanEditMessages.Encode(e) + } + } + { + if s.CanPinMessages.Set { + e.FieldStart("can_pin_messages") + s.CanPinMessages.Encode(e) + } + } + { + if s.CustomTitle.Set { + e.FieldStart("custom_title") + s.CustomTitle.Encode(e) + } + } + } case ChatMemberBannedChatMember: e.FieldStart("status") e.Str("ChatMemberBanned") - s.ChatMemberBanned.encodeFields(e) + { + s := s.ChatMemberBanned + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("until_date") + e.Int(s.UntilDate) + } + } case ChatMemberLeftChatMember: e.FieldStart("status") e.Str("ChatMemberLeft") - s.ChatMemberLeft.encodeFields(e) + { + s := s.ChatMemberLeft + { + e.FieldStart("user") + s.User.Encode(e) + } + } case ChatMemberMemberChatMember: e.FieldStart("status") e.Str("ChatMemberMember") - s.ChatMemberMember.encodeFields(e) + { + s := s.ChatMemberMember + { + e.FieldStart("user") + s.User.Encode(e) + } + } case ChatMemberOwnerChatMember: e.FieldStart("status") e.Str("ChatMemberOwner") - s.ChatMemberOwner.encodeFields(e) + { + s := s.ChatMemberOwner + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("is_anonymous") + e.Bool(s.IsAnonymous) + } + { + if s.CustomTitle.Set { + e.FieldStart("custom_title") + s.CustomTitle.Encode(e) + } + } + } case ChatMemberRestrictedChatMember: e.FieldStart("status") e.Str("ChatMemberRestricted") - s.ChatMemberRestricted.encodeFields(e) + { + s := s.ChatMemberRestricted + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("is_member") + e.Bool(s.IsMember) + } + { + e.FieldStart("can_change_info") + e.Bool(s.CanChangeInfo) + } + { + e.FieldStart("can_invite_users") + e.Bool(s.CanInviteUsers) + } + { + e.FieldStart("can_pin_messages") + e.Bool(s.CanPinMessages) + } + { + e.FieldStart("can_send_messages") + e.Bool(s.CanSendMessages) + } + { + e.FieldStart("can_send_media_messages") + e.Bool(s.CanSendMediaMessages) + } + { + e.FieldStart("can_send_polls") + e.Bool(s.CanSendPolls) + } + { + e.FieldStart("can_send_other_messages") + e.Bool(s.CanSendOtherMessages) + } + { + e.FieldStart("can_add_web_page_previews") + e.Bool(s.CanAddWebPagePreviews) + } + { + e.FieldStart("until_date") + e.Int(s.UntilDate) + } + } } } @@ -12386,55 +12554,851 @@ func (s InlineQueryResult) encodeFields(e *jx.Encoder) { case InlineQueryResultArticleInlineQueryResult: e.FieldStart("type") e.Str("article") - s.InlineQueryResultArticle.encodeFields(e) + { + s := s.InlineQueryResultArticle + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } + { + if s.HideURL.Set { + e.FieldStart("hide_url") + s.HideURL.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultAudioInlineQueryResult: e.FieldStart("type") e.Str("audio") - s.InlineQueryResultAudio.encodeFields(e) + { + s := s.InlineQueryResultAudio + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("audio_url") + e.Str(s.AudioURL) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Performer.Set { + e.FieldStart("performer") + s.Performer.Encode(e) + } + } + { + if s.AudioDuration.Set { + e.FieldStart("audio_duration") + s.AudioDuration.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultContactInlineQueryResult: e.FieldStart("type") e.Str("contact") - s.InlineQueryResultContact.encodeFields(e) + { + s := s.InlineQueryResultContact + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("phone_number") + e.Str(s.PhoneNumber) + } + { + e.FieldStart("first_name") + e.Str(s.FirstName) + } + { + if s.LastName.Set { + e.FieldStart("last_name") + s.LastName.Encode(e) + } + } + { + if s.Vcard.Set { + e.FieldStart("vcard") + s.Vcard.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultDocumentInlineQueryResult: e.FieldStart("type") e.Str("document") - s.InlineQueryResultDocument.encodeFields(e) + { + s := s.InlineQueryResultDocument + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + e.FieldStart("document_url") + e.Str(s.DocumentURL) + } + { + e.FieldStart("mime_type") + e.Str(s.MimeType) + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultGameInlineQueryResult: e.FieldStart("type") e.Str("game") - s.InlineQueryResultGame.encodeFields(e) + { + s := s.InlineQueryResultGame + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("game_short_name") + e.Str(s.GameShortName) + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + } case InlineQueryResultGifInlineQueryResult: e.FieldStart("type") e.Str("gif") - s.InlineQueryResultGif.encodeFields(e) + { + s := s.InlineQueryResultGif + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("gif_url") + e.Str(s.GIFURL) + } + { + if s.GIFWidth.Set { + e.FieldStart("gif_width") + s.GIFWidth.Encode(e) + } + } + { + if s.GIFHeight.Set { + e.FieldStart("gif_height") + s.GIFHeight.Encode(e) + } + } + { + if s.GIFDuration.Set { + e.FieldStart("gif_duration") + s.GIFDuration.Encode(e) + } + } + { + e.FieldStart("thumb_url") + e.Str(s.ThumbURL) + } + { + if s.ThumbMimeType.Set { + e.FieldStart("thumb_mime_type") + s.ThumbMimeType.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultLocationInlineQueryResult: e.FieldStart("type") e.Str("location") - s.InlineQueryResultLocation.encodeFields(e) + { + s := s.InlineQueryResultLocation + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("latitude") + e.Float64(s.Latitude) + } + { + e.FieldStart("longitude") + e.Float64(s.Longitude) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.HorizontalAccuracy.Set { + e.FieldStart("horizontal_accuracy") + s.HorizontalAccuracy.Encode(e) + } + } + { + if s.LivePeriod.Set { + e.FieldStart("live_period") + s.LivePeriod.Encode(e) + } + } + { + if s.Heading.Set { + e.FieldStart("heading") + s.Heading.Encode(e) + } + } + { + if s.ProximityAlertRadius.Set { + e.FieldStart("proximity_alert_radius") + s.ProximityAlertRadius.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultMpeg4GifInlineQueryResult: e.FieldStart("type") e.Str("mpeg4_gif") - s.InlineQueryResultMpeg4Gif.encodeFields(e) + { + s := s.InlineQueryResultMpeg4Gif + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("mpeg4_url") + e.Str(s.Mpeg4URL) + } + { + if s.Mpeg4Width.Set { + e.FieldStart("mpeg4_width") + s.Mpeg4Width.Encode(e) + } + } + { + if s.Mpeg4Height.Set { + e.FieldStart("mpeg4_height") + s.Mpeg4Height.Encode(e) + } + } + { + if s.Mpeg4Duration.Set { + e.FieldStart("mpeg4_duration") + s.Mpeg4Duration.Encode(e) + } + } + { + e.FieldStart("thumb_url") + e.Str(s.ThumbURL) + } + { + if s.ThumbMimeType.Set { + e.FieldStart("thumb_mime_type") + s.ThumbMimeType.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultPhotoInlineQueryResult: e.FieldStart("type") e.Str("photo") - s.InlineQueryResultPhoto.encodeFields(e) + { + s := s.InlineQueryResultPhoto + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("photo_url") + e.Str(s.PhotoURL) + } + { + e.FieldStart("thumb_url") + e.Str(s.ThumbURL) + } + { + if s.PhotoWidth.Set { + e.FieldStart("photo_width") + s.PhotoWidth.Encode(e) + } + } + { + if s.PhotoHeight.Set { + e.FieldStart("photo_height") + s.PhotoHeight.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultCachedStickerInlineQueryResult: e.FieldStart("type") e.Str("sticker") - s.InlineQueryResultCachedSticker.encodeFields(e) + { + s := s.InlineQueryResultCachedSticker + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("sticker_file_id") + e.Str(s.StickerFileID) + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultVenueInlineQueryResult: e.FieldStart("type") e.Str("venue") - s.InlineQueryResultVenue.encodeFields(e) + { + s := s.InlineQueryResultVenue + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("latitude") + e.Float64(s.Latitude) + } + { + e.FieldStart("longitude") + e.Float64(s.Longitude) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + e.FieldStart("address") + e.Str(s.Address) + } + { + if s.FoursquareID.Set { + e.FieldStart("foursquare_id") + s.FoursquareID.Encode(e) + } + } + { + if s.FoursquareType.Set { + e.FieldStart("foursquare_type") + s.FoursquareType.Encode(e) + } + } + { + if s.GooglePlaceID.Set { + e.FieldStart("google_place_id") + s.GooglePlaceID.Encode(e) + } + } + { + if s.GooglePlaceType.Set { + e.FieldStart("google_place_type") + s.GooglePlaceType.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultVideoInlineQueryResult: e.FieldStart("type") e.Str("video") - s.InlineQueryResultVideo.encodeFields(e) + { + s := s.InlineQueryResultVideo + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("video_url") + e.Str(s.VideoURL) + } + { + e.FieldStart("mime_type") + e.Str(s.MimeType) + } + { + e.FieldStart("thumb_url") + e.Str(s.ThumbURL) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.VideoWidth.Set { + e.FieldStart("video_width") + s.VideoWidth.Encode(e) + } + } + { + if s.VideoHeight.Set { + e.FieldStart("video_height") + s.VideoHeight.Encode(e) + } + } + { + if s.VideoDuration.Set { + e.FieldStart("video_duration") + s.VideoDuration.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultVoiceInlineQueryResult: e.FieldStart("type") e.Str("voice") - s.InlineQueryResultVoice.encodeFields(e) + { + s := s.InlineQueryResultVoice + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("voice_url") + e.Str(s.VoiceURL) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.VoiceDuration.Set { + e.FieldStart("voice_duration") + s.VoiceDuration.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } } } @@ -18838,23 +19802,253 @@ func (s InputMedia) encodeFields(e *jx.Encoder) { case InputMediaAnimationInputMedia: e.FieldStart("type") e.Str("animation") - s.InputMediaAnimation.encodeFields(e) + { + s := s.InputMediaAnimation + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + } case InputMediaAudioInputMedia: e.FieldStart("type") e.Str("audio") - s.InputMediaAudio.encodeFields(e) + { + s := s.InputMediaAudio + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.Performer.Set { + e.FieldStart("performer") + s.Performer.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + } case InputMediaDocumentInputMedia: e.FieldStart("type") e.Str("document") - s.InputMediaDocument.encodeFields(e) + { + s := s.InputMediaDocument + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.DisableContentTypeDetection.Set { + e.FieldStart("disable_content_type_detection") + s.DisableContentTypeDetection.Encode(e) + } + } + } case InputMediaPhotoInputMedia: e.FieldStart("type") e.Str("photo") - s.InputMediaPhoto.encodeFields(e) + { + s := s.InputMediaPhoto + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + } case InputMediaVideoInputMedia: e.FieldStart("type") e.Str("video") - s.InputMediaVideo.encodeFields(e) + { + s := s.InputMediaVideo + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.SupportsStreaming.Set { + e.FieldStart("supports_streaming") + s.SupportsStreaming.Encode(e) + } + } + } } } @@ -21975,15 +23169,23 @@ func (s MenuButton) encodeFields(e *jx.Encoder) { case MenuButtonCommandsMenuButton: e.FieldStart("type") e.Str("commands") - s.MenuButtonCommands.encodeFields(e) case MenuButtonDefaultMenuButton: e.FieldStart("type") e.Str("default") - s.MenuButtonDefault.encodeFields(e) case MenuButtonWebAppMenuButton: e.FieldStart("type") e.Str("web_app") - s.MenuButtonWebApp.encodeFields(e) + { + s := s.MenuButtonWebApp + { + e.FieldStart("text") + e.Str(s.Text) + } + { + e.FieldStart("web_app") + s.WebApp.Encode(e) + } + } } } @@ -26725,39 +27927,177 @@ func (s PassportElementError) encodeFields(e *jx.Encoder) { case PassportElementErrorDataFieldPassportElementError: e.FieldStart("type") e.Str("data") - s.PassportElementErrorDataField.encodeFields(e) + { + s := s.PassportElementErrorDataField + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("field_name") + e.Str(s.FieldName) + } + { + e.FieldStart("data_hash") + e.Str(s.DataHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorFilePassportElementError: e.FieldStart("type") e.Str("file") - s.PassportElementErrorFile.encodeFields(e) + { + s := s.PassportElementErrorFile + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorFilesPassportElementError: e.FieldStart("type") e.Str("files") - s.PassportElementErrorFiles.encodeFields(e) + { + s := s.PassportElementErrorFiles + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hashes") + e.ArrStart() + for _, elem := range s.FileHashes { + e.Str(elem) + } + e.ArrEnd() + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorFrontSidePassportElementError: e.FieldStart("type") e.Str("front_side") - s.PassportElementErrorFrontSide.encodeFields(e) + { + s := s.PassportElementErrorFrontSide + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorReverseSidePassportElementError: e.FieldStart("type") e.Str("reverse_side") - s.PassportElementErrorReverseSide.encodeFields(e) + { + s := s.PassportElementErrorReverseSide + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorSelfiePassportElementError: e.FieldStart("type") e.Str("selfie") - s.PassportElementErrorSelfie.encodeFields(e) + { + s := s.PassportElementErrorSelfie + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorTranslationFilePassportElementError: e.FieldStart("type") e.Str("translation_file") - s.PassportElementErrorTranslationFile.encodeFields(e) + { + s := s.PassportElementErrorTranslationFile + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorTranslationFilesPassportElementError: e.FieldStart("type") e.Str("translation_files") - s.PassportElementErrorTranslationFiles.encodeFields(e) + { + s := s.PassportElementErrorTranslationFiles + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hashes") + e.ArrStart() + for _, elem := range s.FileHashes { + e.Str(elem) + } + e.ArrEnd() + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorUnspecifiedPassportElementError: e.FieldStart("type") e.Str("unspecified") - s.PassportElementErrorUnspecified.encodeFields(e) + { + s := s.PassportElementErrorUnspecified + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("element_hash") + e.Str(s.ElementHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } } } @@ -36047,19 +37387,197 @@ func (s SendMediaGroupMediaItem) encodeFields(e *jx.Encoder) { case InputMediaAudioSendMediaGroupMediaItem: e.FieldStart("type") e.Str("audio") - s.InputMediaAudio.encodeFields(e) + { + s := s.InputMediaAudio + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.Performer.Set { + e.FieldStart("performer") + s.Performer.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + } case InputMediaDocumentSendMediaGroupMediaItem: e.FieldStart("type") e.Str("document") - s.InputMediaDocument.encodeFields(e) + { + s := s.InputMediaDocument + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.DisableContentTypeDetection.Set { + e.FieldStart("disable_content_type_detection") + s.DisableContentTypeDetection.Encode(e) + } + } + } case InputMediaPhotoSendMediaGroupMediaItem: e.FieldStart("type") e.Str("photo") - s.InputMediaPhoto.encodeFields(e) + { + s := s.InputMediaPhoto + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + } case InputMediaVideoSendMediaGroupMediaItem: e.FieldStart("type") e.Str("video") - s.InputMediaVideo.encodeFields(e) + { + s := s.InputMediaVideo + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.SupportsStreaming.Set { + e.FieldStart("supports_streaming") + s.SupportsStreaming.Encode(e) + } + } + } } } diff --git a/examples/ex_telegram/oas_json_gen.go b/examples/ex_telegram/oas_json_gen.go index ceb8f00c6..6515cd7f2 100644 --- a/examples/ex_telegram/oas_json_gen.go +++ b/examples/ex_telegram/oas_json_gen.go @@ -1812,31 +1812,49 @@ func (s BotCommandScope) encodeFields(e *jx.Encoder) { case BotCommandScopeAllChatAdministratorsBotCommandScope: e.FieldStart("type") e.Str("all_chat_administrators") - s.BotCommandScopeAllChatAdministrators.encodeFields(e) case BotCommandScopeAllGroupChatsBotCommandScope: e.FieldStart("type") e.Str("all_group_chats") - s.BotCommandScopeAllGroupChats.encodeFields(e) case BotCommandScopeAllPrivateChatsBotCommandScope: e.FieldStart("type") e.Str("all_private_chats") - s.BotCommandScopeAllPrivateChats.encodeFields(e) case BotCommandScopeChatBotCommandScope: e.FieldStart("type") e.Str("chat") - s.BotCommandScopeChat.encodeFields(e) + { + s := s.BotCommandScopeChat + { + e.FieldStart("chat_id") + s.ChatID.Encode(e) + } + } case BotCommandScopeChatAdministratorsBotCommandScope: e.FieldStart("type") e.Str("chat_administrators") - s.BotCommandScopeChatAdministrators.encodeFields(e) + { + s := s.BotCommandScopeChatAdministrators + { + e.FieldStart("chat_id") + s.ChatID.Encode(e) + } + } case BotCommandScopeChatMemberBotCommandScope: e.FieldStart("type") e.Str("chat_member") - s.BotCommandScopeChatMember.encodeFields(e) + { + s := s.BotCommandScopeChatMember + { + e.FieldStart("chat_id") + s.ChatID.Encode(e) + } + { + e.FieldStart("user_id") + e.Int64(s.UserID) + } + } case BotCommandScopeDefaultBotCommandScope: e.FieldStart("type") e.Str("default") - s.BotCommandScopeDefault.encodeFields(e) } } @@ -3861,27 +3879,177 @@ func (s ChatMember) encodeFields(e *jx.Encoder) { case ChatMemberAdministratorChatMember: e.FieldStart("status") e.Str("ChatMemberAdministrator") - s.ChatMemberAdministrator.encodeFields(e) + { + s := s.ChatMemberAdministrator + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("can_be_edited") + e.Bool(s.CanBeEdited) + } + { + e.FieldStart("is_anonymous") + e.Bool(s.IsAnonymous) + } + { + e.FieldStart("can_manage_chat") + e.Bool(s.CanManageChat) + } + { + e.FieldStart("can_delete_messages") + e.Bool(s.CanDeleteMessages) + } + { + e.FieldStart("can_manage_voice_chats") + e.Bool(s.CanManageVoiceChats) + } + { + e.FieldStart("can_restrict_members") + e.Bool(s.CanRestrictMembers) + } + { + e.FieldStart("can_promote_members") + e.Bool(s.CanPromoteMembers) + } + { + e.FieldStart("can_change_info") + e.Bool(s.CanChangeInfo) + } + { + e.FieldStart("can_invite_users") + e.Bool(s.CanInviteUsers) + } + { + if s.CanPostMessages.Set { + e.FieldStart("can_post_messages") + s.CanPostMessages.Encode(e) + } + } + { + if s.CanEditMessages.Set { + e.FieldStart("can_edit_messages") + s.CanEditMessages.Encode(e) + } + } + { + if s.CanPinMessages.Set { + e.FieldStart("can_pin_messages") + s.CanPinMessages.Encode(e) + } + } + { + if s.CustomTitle.Set { + e.FieldStart("custom_title") + s.CustomTitle.Encode(e) + } + } + } case ChatMemberBannedChatMember: e.FieldStart("status") e.Str("ChatMemberBanned") - s.ChatMemberBanned.encodeFields(e) + { + s := s.ChatMemberBanned + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("until_date") + e.Int(s.UntilDate) + } + } case ChatMemberLeftChatMember: e.FieldStart("status") e.Str("ChatMemberLeft") - s.ChatMemberLeft.encodeFields(e) + { + s := s.ChatMemberLeft + { + e.FieldStart("user") + s.User.Encode(e) + } + } case ChatMemberMemberChatMember: e.FieldStart("status") e.Str("ChatMemberMember") - s.ChatMemberMember.encodeFields(e) + { + s := s.ChatMemberMember + { + e.FieldStart("user") + s.User.Encode(e) + } + } case ChatMemberOwnerChatMember: e.FieldStart("status") e.Str("ChatMemberOwner") - s.ChatMemberOwner.encodeFields(e) + { + s := s.ChatMemberOwner + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("is_anonymous") + e.Bool(s.IsAnonymous) + } + { + if s.CustomTitle.Set { + e.FieldStart("custom_title") + s.CustomTitle.Encode(e) + } + } + } case ChatMemberRestrictedChatMember: e.FieldStart("status") e.Str("ChatMemberRestricted") - s.ChatMemberRestricted.encodeFields(e) + { + s := s.ChatMemberRestricted + { + e.FieldStart("user") + s.User.Encode(e) + } + { + e.FieldStart("is_member") + e.Bool(s.IsMember) + } + { + e.FieldStart("can_change_info") + e.Bool(s.CanChangeInfo) + } + { + e.FieldStart("can_invite_users") + e.Bool(s.CanInviteUsers) + } + { + e.FieldStart("can_pin_messages") + e.Bool(s.CanPinMessages) + } + { + e.FieldStart("can_send_messages") + e.Bool(s.CanSendMessages) + } + { + e.FieldStart("can_send_media_messages") + e.Bool(s.CanSendMediaMessages) + } + { + e.FieldStart("can_send_polls") + e.Bool(s.CanSendPolls) + } + { + e.FieldStart("can_send_other_messages") + e.Bool(s.CanSendOtherMessages) + } + { + e.FieldStart("can_add_web_page_previews") + e.Bool(s.CanAddWebPagePreviews) + } + { + e.FieldStart("until_date") + e.Int(s.UntilDate) + } + } } } @@ -11913,55 +12081,851 @@ func (s InlineQueryResult) encodeFields(e *jx.Encoder) { case InlineQueryResultArticleInlineQueryResult: e.FieldStart("type") e.Str("article") - s.InlineQueryResultArticle.encodeFields(e) + { + s := s.InlineQueryResultArticle + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } + { + if s.HideURL.Set { + e.FieldStart("hide_url") + s.HideURL.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultAudioInlineQueryResult: e.FieldStart("type") e.Str("audio") - s.InlineQueryResultAudio.encodeFields(e) + { + s := s.InlineQueryResultAudio + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("audio_url") + json.EncodeURI(e, s.AudioURL) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Performer.Set { + e.FieldStart("performer") + s.Performer.Encode(e) + } + } + { + if s.AudioDuration.Set { + e.FieldStart("audio_duration") + s.AudioDuration.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultContactInlineQueryResult: e.FieldStart("type") e.Str("contact") - s.InlineQueryResultContact.encodeFields(e) + { + s := s.InlineQueryResultContact + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("phone_number") + e.Str(s.PhoneNumber) + } + { + e.FieldStart("first_name") + e.Str(s.FirstName) + } + { + if s.LastName.Set { + e.FieldStart("last_name") + s.LastName.Encode(e) + } + } + { + if s.Vcard.Set { + e.FieldStart("vcard") + s.Vcard.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultDocumentInlineQueryResult: e.FieldStart("type") e.Str("document") - s.InlineQueryResultDocument.encodeFields(e) + { + s := s.InlineQueryResultDocument + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + e.FieldStart("document_url") + json.EncodeURI(e, s.DocumentURL) + } + { + e.FieldStart("mime_type") + e.Str(s.MimeType) + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultGameInlineQueryResult: e.FieldStart("type") e.Str("game") - s.InlineQueryResultGame.encodeFields(e) + { + s := s.InlineQueryResultGame + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("game_short_name") + e.Str(s.GameShortName) + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + } case InlineQueryResultGifInlineQueryResult: e.FieldStart("type") e.Str("gif") - s.InlineQueryResultGif.encodeFields(e) + { + s := s.InlineQueryResultGif + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("gif_url") + json.EncodeURI(e, s.GIFURL) + } + { + if s.GIFWidth.Set { + e.FieldStart("gif_width") + s.GIFWidth.Encode(e) + } + } + { + if s.GIFHeight.Set { + e.FieldStart("gif_height") + s.GIFHeight.Encode(e) + } + } + { + if s.GIFDuration.Set { + e.FieldStart("gif_duration") + s.GIFDuration.Encode(e) + } + } + { + e.FieldStart("thumb_url") + json.EncodeURI(e, s.ThumbURL) + } + { + if s.ThumbMimeType.Set { + e.FieldStart("thumb_mime_type") + s.ThumbMimeType.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultLocationInlineQueryResult: e.FieldStart("type") e.Str("location") - s.InlineQueryResultLocation.encodeFields(e) + { + s := s.InlineQueryResultLocation + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("latitude") + e.Float64(s.Latitude) + } + { + e.FieldStart("longitude") + e.Float64(s.Longitude) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.HorizontalAccuracy.Set { + e.FieldStart("horizontal_accuracy") + s.HorizontalAccuracy.Encode(e) + } + } + { + if s.LivePeriod.Set { + e.FieldStart("live_period") + s.LivePeriod.Encode(e) + } + } + { + if s.Heading.Set { + e.FieldStart("heading") + s.Heading.Encode(e) + } + } + { + if s.ProximityAlertRadius.Set { + e.FieldStart("proximity_alert_radius") + s.ProximityAlertRadius.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultMpeg4GifInlineQueryResult: e.FieldStart("type") e.Str("mpeg4_gif") - s.InlineQueryResultMpeg4Gif.encodeFields(e) + { + s := s.InlineQueryResultMpeg4Gif + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("mpeg4_url") + json.EncodeURI(e, s.Mpeg4URL) + } + { + if s.Mpeg4Width.Set { + e.FieldStart("mpeg4_width") + s.Mpeg4Width.Encode(e) + } + } + { + if s.Mpeg4Height.Set { + e.FieldStart("mpeg4_height") + s.Mpeg4Height.Encode(e) + } + } + { + if s.Mpeg4Duration.Set { + e.FieldStart("mpeg4_duration") + s.Mpeg4Duration.Encode(e) + } + } + { + e.FieldStart("thumb_url") + json.EncodeURI(e, s.ThumbURL) + } + { + if s.ThumbMimeType.Set { + e.FieldStart("thumb_mime_type") + s.ThumbMimeType.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultPhotoInlineQueryResult: e.FieldStart("type") e.Str("photo") - s.InlineQueryResultPhoto.encodeFields(e) + { + s := s.InlineQueryResultPhoto + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("photo_url") + json.EncodeURI(e, s.PhotoURL) + } + { + e.FieldStart("thumb_url") + json.EncodeURI(e, s.ThumbURL) + } + { + if s.PhotoWidth.Set { + e.FieldStart("photo_width") + s.PhotoWidth.Encode(e) + } + } + { + if s.PhotoHeight.Set { + e.FieldStart("photo_height") + s.PhotoHeight.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultCachedStickerInlineQueryResult: e.FieldStart("type") e.Str("sticker") - s.InlineQueryResultCachedSticker.encodeFields(e) + { + s := s.InlineQueryResultCachedSticker + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("sticker_file_id") + e.Str(s.StickerFileID) + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultVenueInlineQueryResult: e.FieldStart("type") e.Str("venue") - s.InlineQueryResultVenue.encodeFields(e) + { + s := s.InlineQueryResultVenue + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("latitude") + e.Float64(s.Latitude) + } + { + e.FieldStart("longitude") + e.Float64(s.Longitude) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + e.FieldStart("address") + e.Str(s.Address) + } + { + if s.FoursquareID.Set { + e.FieldStart("foursquare_id") + s.FoursquareID.Encode(e) + } + } + { + if s.FoursquareType.Set { + e.FieldStart("foursquare_type") + s.FoursquareType.Encode(e) + } + } + { + if s.GooglePlaceID.Set { + e.FieldStart("google_place_id") + s.GooglePlaceID.Encode(e) + } + } + { + if s.GooglePlaceType.Set { + e.FieldStart("google_place_type") + s.GooglePlaceType.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + { + if s.ThumbURL.Set { + e.FieldStart("thumb_url") + s.ThumbURL.Encode(e) + } + } + { + if s.ThumbWidth.Set { + e.FieldStart("thumb_width") + s.ThumbWidth.Encode(e) + } + } + { + if s.ThumbHeight.Set { + e.FieldStart("thumb_height") + s.ThumbHeight.Encode(e) + } + } + } case InlineQueryResultVideoInlineQueryResult: e.FieldStart("type") e.Str("video") - s.InlineQueryResultVideo.encodeFields(e) + { + s := s.InlineQueryResultVideo + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("video_url") + json.EncodeURI(e, s.VideoURL) + } + { + e.FieldStart("mime_type") + e.Str(s.MimeType) + } + { + e.FieldStart("thumb_url") + json.EncodeURI(e, s.ThumbURL) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.VideoWidth.Set { + e.FieldStart("video_width") + s.VideoWidth.Encode(e) + } + } + { + if s.VideoHeight.Set { + e.FieldStart("video_height") + s.VideoHeight.Encode(e) + } + } + { + if s.VideoDuration.Set { + e.FieldStart("video_duration") + s.VideoDuration.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } case InlineQueryResultVoiceInlineQueryResult: e.FieldStart("type") e.Str("voice") - s.InlineQueryResultVoice.encodeFields(e) + { + s := s.InlineQueryResultVoice + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("voice_url") + json.EncodeURI(e, s.VoiceURL) + } + { + e.FieldStart("title") + e.Str(s.Title) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.VoiceDuration.Set { + e.FieldStart("voice_duration") + s.VoiceDuration.Encode(e) + } + } + { + if s.ReplyMarkup.Set { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) + } + } + { + if s.InputMessageContent.Set { + e.FieldStart("input_message_content") + s.InputMessageContent.Encode(e) + } + } + } } } @@ -18365,23 +19329,253 @@ func (s InputMedia) encodeFields(e *jx.Encoder) { case InputMediaAnimationInputMedia: e.FieldStart("type") e.Str("animation") - s.InputMediaAnimation.encodeFields(e) + { + s := s.InputMediaAnimation + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + } case InputMediaAudioInputMedia: e.FieldStart("type") e.Str("audio") - s.InputMediaAudio.encodeFields(e) + { + s := s.InputMediaAudio + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.Performer.Set { + e.FieldStart("performer") + s.Performer.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + } case InputMediaDocumentInputMedia: e.FieldStart("type") e.Str("document") - s.InputMediaDocument.encodeFields(e) + { + s := s.InputMediaDocument + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.DisableContentTypeDetection.Set { + e.FieldStart("disable_content_type_detection") + s.DisableContentTypeDetection.Encode(e) + } + } + } case InputMediaPhotoInputMedia: e.FieldStart("type") e.Str("photo") - s.InputMediaPhoto.encodeFields(e) + { + s := s.InputMediaPhoto + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + } case InputMediaVideoInputMedia: e.FieldStart("type") e.Str("video") - s.InputMediaVideo.encodeFields(e) + { + s := s.InputMediaVideo + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.SupportsStreaming.Set { + e.FieldStart("supports_streaming") + s.SupportsStreaming.Encode(e) + } + } + } } } @@ -25908,39 +27102,177 @@ func (s PassportElementError) encodeFields(e *jx.Encoder) { case PassportElementErrorDataFieldPassportElementError: e.FieldStart("type") e.Str("data") - s.PassportElementErrorDataField.encodeFields(e) + { + s := s.PassportElementErrorDataField + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("field_name") + e.Str(s.FieldName) + } + { + e.FieldStart("data_hash") + e.Str(s.DataHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorFilePassportElementError: e.FieldStart("type") e.Str("file") - s.PassportElementErrorFile.encodeFields(e) + { + s := s.PassportElementErrorFile + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorFilesPassportElementError: e.FieldStart("type") e.Str("files") - s.PassportElementErrorFiles.encodeFields(e) + { + s := s.PassportElementErrorFiles + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hashes") + e.ArrStart() + for _, elem := range s.FileHashes { + e.Str(elem) + } + e.ArrEnd() + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorFrontSidePassportElementError: e.FieldStart("type") e.Str("front_side") - s.PassportElementErrorFrontSide.encodeFields(e) + { + s := s.PassportElementErrorFrontSide + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorReverseSidePassportElementError: e.FieldStart("type") e.Str("reverse_side") - s.PassportElementErrorReverseSide.encodeFields(e) + { + s := s.PassportElementErrorReverseSide + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorSelfiePassportElementError: e.FieldStart("type") e.Str("selfie") - s.PassportElementErrorSelfie.encodeFields(e) + { + s := s.PassportElementErrorSelfie + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorTranslationFilePassportElementError: e.FieldStart("type") e.Str("translation_file") - s.PassportElementErrorTranslationFile.encodeFields(e) + { + s := s.PassportElementErrorTranslationFile + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hash") + e.Str(s.FileHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorTranslationFilesPassportElementError: e.FieldStart("type") e.Str("translation_files") - s.PassportElementErrorTranslationFiles.encodeFields(e) + { + s := s.PassportElementErrorTranslationFiles + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("file_hashes") + e.ArrStart() + for _, elem := range s.FileHashes { + e.Str(elem) + } + e.ArrEnd() + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } case PassportElementErrorUnspecifiedPassportElementError: e.FieldStart("type") e.Str("unspecified") - s.PassportElementErrorUnspecified.encodeFields(e) + { + s := s.PassportElementErrorUnspecified + { + e.FieldStart("source") + e.Str(s.Source) + } + { + e.FieldStart("element_hash") + e.Str(s.ElementHash) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + } } } @@ -35605,19 +36937,197 @@ func (s SendMediaGroupMediaItem) encodeFields(e *jx.Encoder) { case InputMediaAudioSendMediaGroupMediaItem: e.FieldStart("type") e.Str("audio") - s.InputMediaAudio.encodeFields(e) + { + s := s.InputMediaAudio + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.Performer.Set { + e.FieldStart("performer") + s.Performer.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + } case InputMediaDocumentSendMediaGroupMediaItem: e.FieldStart("type") e.Str("document") - s.InputMediaDocument.encodeFields(e) + { + s := s.InputMediaDocument + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.DisableContentTypeDetection.Set { + e.FieldStart("disable_content_type_detection") + s.DisableContentTypeDetection.Encode(e) + } + } + } case InputMediaPhotoSendMediaGroupMediaItem: e.FieldStart("type") e.Str("photo") - s.InputMediaPhoto.encodeFields(e) + { + s := s.InputMediaPhoto + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + } case InputMediaVideoSendMediaGroupMediaItem: e.FieldStart("type") e.Str("video") - s.InputMediaVideo.encodeFields(e) + { + s := s.InputMediaVideo + { + e.FieldStart("media") + e.Str(s.Media) + } + { + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + } + { + if s.Caption.Set { + e.FieldStart("caption") + s.Caption.Encode(e) + } + } + { + if s.ParseMode.Set { + e.FieldStart("parse_mode") + s.ParseMode.Encode(e) + } + } + { + if s.CaptionEntities != nil { + e.FieldStart("caption_entities") + e.ArrStart() + for _, elem := range s.CaptionEntities { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } + { + if s.Duration.Set { + e.FieldStart("duration") + s.Duration.Encode(e) + } + } + { + if s.SupportsStreaming.Set { + e.FieldStart("supports_streaming") + s.SupportsStreaming.Encode(e) + } + } + } } } diff --git a/internal/integration/sample_api/oas_json_gen.go b/internal/integration/sample_api/oas_json_gen.go index cce2e0864..be3fdeb67 100644 --- a/internal/integration/sample_api/oas_json_gen.go +++ b/internal/integration/sample_api/oas_json_gen.go @@ -1553,11 +1553,27 @@ func (s InlineDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -2629,15 +2645,34 @@ func (s Issue943) encodeFields(e *jx.Encoder) { case Issue943Variant1Issue943: e.FieldStart("selector") e.Str("variant1") - s.Issue943Variant1.encodeFields(e) + { + s := s.Issue943Variant1 + { + e.FieldStart("variant1_field") + e.Int(s.Variant1Field) + } + } case Issue943Variant2Issue943: e.FieldStart("selector") e.Str("variant2") - s.Issue943Variant2.encodeFields(e) + { + s := s.Issue943Variant2 + { + e.FieldStart("variant2_field") + e.Bool(s.Variant2Field) + } + } case Issue943MapIssue943: e.FieldStart("selector") e.Str("variant3") - s.Issue943Map.encodeFields(e) + { + s := s.Issue943Map + for k, elem := range s.Pattern0Props { + e.FieldStart(k) + + e.Str(elem) + } + } } } @@ -3707,11 +3742,27 @@ func (s MergeDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -4799,11 +4850,39 @@ func (s OneOfMappingReference) encodeFields(e *jx.Encoder) { case OneOfMappingReferenceBOneOfMappingReference: e.FieldStart("infoType") e.Str("extended") - s.OneOfMappingReferenceB.encodeFields(e) + { + s := s.OneOfMappingReferenceB + { + if s.Code.Set { + e.FieldStart("code") + s.Code.Encode(e) + } + } + { + if s.Data != nil { + e.FieldStart("data") + s.Data.Encode(e) + } + } + { + if s.Info.Set { + e.FieldStart("info") + s.Info.Encode(e) + } + } + } case OneOfMappingReferenceAOneOfMappingReference: e.FieldStart("infoType") e.Str("simple") - s.OneOfMappingReferenceA.encodeFields(e) + { + s := s.OneOfMappingReferenceA + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + } } } diff --git a/internal/integration/sample_api_nc/oas_json_gen.go b/internal/integration/sample_api_nc/oas_json_gen.go index cce2e0864..be3fdeb67 100644 --- a/internal/integration/sample_api_nc/oas_json_gen.go +++ b/internal/integration/sample_api_nc/oas_json_gen.go @@ -1553,11 +1553,27 @@ func (s InlineDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -2629,15 +2645,34 @@ func (s Issue943) encodeFields(e *jx.Encoder) { case Issue943Variant1Issue943: e.FieldStart("selector") e.Str("variant1") - s.Issue943Variant1.encodeFields(e) + { + s := s.Issue943Variant1 + { + e.FieldStart("variant1_field") + e.Int(s.Variant1Field) + } + } case Issue943Variant2Issue943: e.FieldStart("selector") e.Str("variant2") - s.Issue943Variant2.encodeFields(e) + { + s := s.Issue943Variant2 + { + e.FieldStart("variant2_field") + e.Bool(s.Variant2Field) + } + } case Issue943MapIssue943: e.FieldStart("selector") e.Str("variant3") - s.Issue943Map.encodeFields(e) + { + s := s.Issue943Map + for k, elem := range s.Pattern0Props { + e.FieldStart(k) + + e.Str(elem) + } + } } } @@ -3707,11 +3742,27 @@ func (s MergeDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -4799,11 +4850,39 @@ func (s OneOfMappingReference) encodeFields(e *jx.Encoder) { case OneOfMappingReferenceBOneOfMappingReference: e.FieldStart("infoType") e.Str("extended") - s.OneOfMappingReferenceB.encodeFields(e) + { + s := s.OneOfMappingReferenceB + { + if s.Code.Set { + e.FieldStart("code") + s.Code.Encode(e) + } + } + { + if s.Data != nil { + e.FieldStart("data") + s.Data.Encode(e) + } + } + { + if s.Info.Set { + e.FieldStart("info") + s.Info.Encode(e) + } + } + } case OneOfMappingReferenceAOneOfMappingReference: e.FieldStart("infoType") e.Str("simple") - s.OneOfMappingReferenceA.encodeFields(e) + { + s := s.OneOfMappingReferenceA + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + } } } diff --git a/internal/integration/sample_api_no_otel/oas_json_gen.go b/internal/integration/sample_api_no_otel/oas_json_gen.go index cce2e0864..be3fdeb67 100644 --- a/internal/integration/sample_api_no_otel/oas_json_gen.go +++ b/internal/integration/sample_api_no_otel/oas_json_gen.go @@ -1553,11 +1553,27 @@ func (s InlineDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -2629,15 +2645,34 @@ func (s Issue943) encodeFields(e *jx.Encoder) { case Issue943Variant1Issue943: e.FieldStart("selector") e.Str("variant1") - s.Issue943Variant1.encodeFields(e) + { + s := s.Issue943Variant1 + { + e.FieldStart("variant1_field") + e.Int(s.Variant1Field) + } + } case Issue943Variant2Issue943: e.FieldStart("selector") e.Str("variant2") - s.Issue943Variant2.encodeFields(e) + { + s := s.Issue943Variant2 + { + e.FieldStart("variant2_field") + e.Bool(s.Variant2Field) + } + } case Issue943MapIssue943: e.FieldStart("selector") e.Str("variant3") - s.Issue943Map.encodeFields(e) + { + s := s.Issue943Map + for k, elem := range s.Pattern0Props { + e.FieldStart(k) + + e.Str(elem) + } + } } } @@ -3707,11 +3742,27 @@ func (s MergeDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -4799,11 +4850,39 @@ func (s OneOfMappingReference) encodeFields(e *jx.Encoder) { case OneOfMappingReferenceBOneOfMappingReference: e.FieldStart("infoType") e.Str("extended") - s.OneOfMappingReferenceB.encodeFields(e) + { + s := s.OneOfMappingReferenceB + { + if s.Code.Set { + e.FieldStart("code") + s.Code.Encode(e) + } + } + { + if s.Data != nil { + e.FieldStart("data") + s.Data.Encode(e) + } + } + { + if s.Info.Set { + e.FieldStart("info") + s.Info.Encode(e) + } + } + } case OneOfMappingReferenceAOneOfMappingReference: e.FieldStart("infoType") e.Str("simple") - s.OneOfMappingReferenceA.encodeFields(e) + { + s := s.OneOfMappingReferenceA + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + } } } diff --git a/internal/integration/sample_api_ns/oas_json_gen.go b/internal/integration/sample_api_ns/oas_json_gen.go index cce2e0864..be3fdeb67 100644 --- a/internal/integration/sample_api_ns/oas_json_gen.go +++ b/internal/integration/sample_api_ns/oas_json_gen.go @@ -1553,11 +1553,27 @@ func (s InlineDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -2629,15 +2645,34 @@ func (s Issue943) encodeFields(e *jx.Encoder) { case Issue943Variant1Issue943: e.FieldStart("selector") e.Str("variant1") - s.Issue943Variant1.encodeFields(e) + { + s := s.Issue943Variant1 + { + e.FieldStart("variant1_field") + e.Int(s.Variant1Field) + } + } case Issue943Variant2Issue943: e.FieldStart("selector") e.Str("variant2") - s.Issue943Variant2.encodeFields(e) + { + s := s.Issue943Variant2 + { + e.FieldStart("variant2_field") + e.Bool(s.Variant2Field) + } + } case Issue943MapIssue943: e.FieldStart("selector") e.Str("variant3") - s.Issue943Map.encodeFields(e) + { + s := s.Issue943Map + for k, elem := range s.Pattern0Props { + e.FieldStart(k) + + e.Str(elem) + } + } } } @@ -3707,11 +3742,27 @@ func (s MergeDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -4799,11 +4850,39 @@ func (s OneOfMappingReference) encodeFields(e *jx.Encoder) { case OneOfMappingReferenceBOneOfMappingReference: e.FieldStart("infoType") e.Str("extended") - s.OneOfMappingReferenceB.encodeFields(e) + { + s := s.OneOfMappingReferenceB + { + if s.Code.Set { + e.FieldStart("code") + s.Code.Encode(e) + } + } + { + if s.Data != nil { + e.FieldStart("data") + s.Data.Encode(e) + } + } + { + if s.Info.Set { + e.FieldStart("info") + s.Info.Encode(e) + } + } + } case OneOfMappingReferenceAOneOfMappingReference: e.FieldStart("infoType") e.Str("simple") - s.OneOfMappingReferenceA.encodeFields(e) + { + s := s.OneOfMappingReferenceA + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + } } } diff --git a/internal/integration/sample_api_nsnc/oas_json_gen.go b/internal/integration/sample_api_nsnc/oas_json_gen.go index cce2e0864..be3fdeb67 100644 --- a/internal/integration/sample_api_nsnc/oas_json_gen.go +++ b/internal/integration/sample_api_nsnc/oas_json_gen.go @@ -1553,11 +1553,27 @@ func (s InlineDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooInlineDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -2629,15 +2645,34 @@ func (s Issue943) encodeFields(e *jx.Encoder) { case Issue943Variant1Issue943: e.FieldStart("selector") e.Str("variant1") - s.Issue943Variant1.encodeFields(e) + { + s := s.Issue943Variant1 + { + e.FieldStart("variant1_field") + e.Int(s.Variant1Field) + } + } case Issue943Variant2Issue943: e.FieldStart("selector") e.Str("variant2") - s.Issue943Variant2.encodeFields(e) + { + s := s.Issue943Variant2 + { + e.FieldStart("variant2_field") + e.Bool(s.Variant2Field) + } + } case Issue943MapIssue943: e.FieldStart("selector") e.Str("variant3") - s.Issue943Map.encodeFields(e) + { + s := s.Issue943Map + for k, elem := range s.Pattern0Props { + e.FieldStart(k) + + e.Str(elem) + } + } } } @@ -3707,11 +3742,27 @@ func (s MergeDiscriminatorOneOfSum) encodeFields(e *jx.Encoder) { case InlineOneOfBarMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("bar") - s.InlineOneOfBar.encodeFields(e) + { + s := s.InlineOneOfBar + { + if s.Bar.Set { + e.FieldStart("bar") + s.Bar.Encode(e) + } + } + } case InlineOneOfFooMergeDiscriminatorOneOfSum: e.FieldStart("kind") e.Str("foo") - s.InlineOneOfFoo.encodeFields(e) + { + s := s.InlineOneOfFoo + { + if s.Foo.Set { + e.FieldStart("foo") + s.Foo.Encode(e) + } + } + } } } @@ -4799,11 +4850,39 @@ func (s OneOfMappingReference) encodeFields(e *jx.Encoder) { case OneOfMappingReferenceBOneOfMappingReference: e.FieldStart("infoType") e.Str("extended") - s.OneOfMappingReferenceB.encodeFields(e) + { + s := s.OneOfMappingReferenceB + { + if s.Code.Set { + e.FieldStart("code") + s.Code.Encode(e) + } + } + { + if s.Data != nil { + e.FieldStart("data") + s.Data.Encode(e) + } + } + { + if s.Info.Set { + e.FieldStart("info") + s.Info.Encode(e) + } + } + } case OneOfMappingReferenceAOneOfMappingReference: e.FieldStart("infoType") e.Str("simple") - s.OneOfMappingReferenceA.encodeFields(e) + { + s := s.OneOfMappingReferenceA + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + } } }