Skip to content

release v0.8.0-alpha: typed models aligned with MAX OpenAPI schema - #44

Merged
CrazyAngelm merged 3 commits into
mainfrom
claude/sleepy-pasteur-5m5ig8
Oct 30, 2026
Merged

CrazyAngelm merged 3 commits into
mainfrom
claude/sleepy-pasteur-5m5ig8

Conversation

@CrazyAngelm

Copy link
Copy Markdown
Contributor

Отзыв пользователя: JsonSerializer.SerializeToElement("reply").Deserialize<MessageLinkType>() падал, потому что у MessageLinkType не было [JsonConverter]. Кроме того, модели отдавали сырые строки и объекты, а nullability расходилась с документацией, поэтому приходилось много разбирать вручную и ставить null-проверки.

Что сделано

Enum'ы

  • Каждый enum помечен JsonSnakeCaseEnumConverter<TEnum>, а UpdateType — своим UpdateTypeJsonConverter. Enum'ы и модели разбираются и обычным JsonSerializer с опциями по умолчанию.
  • В MaxJsonSerializer.Options общий enum-конвертер перекрывал UpdateTypeJsonConverter. Из-за этого новый тип события (например, comment_created) ронял GET /subscriptions.

Типизированные модели

  • LinkedMessage.Type теперь MessageLinkType?, MessageRecipient.ChatType — ChatType?, MarkupElement.Type — MarkupType?. Неизвестное значение даёт null, а не исключение.
  • InlineKeyboardAttachment.Payload теперь InlineKeyboard вместо Dictionary<string, object>.
  • Типизированы Chat.Participants, Image.Photos, Video.Urls (VideoUrls) и UpdateChatRequest.Icon.

Nullability по схеме

  • Обязательные поля не nullable: Message, MessageBody, User, Chat, ChatMember, CallbackQuery, вложения, Video, Timestamp, а также обязательные поля типизированных обёрток событий.
  • Явный null от API в этих полях превращается в 0, "" или пустой объект и не роняет разбор.

Новое

  • Кнопка chat.
  • Reply-клавиатура: приём через ReplyKeyboardAttachment, отправка через AttachmentRequest.ReplyKeyboard.
  • DataAttachment и UnknownAttachment.
  • ModifyMembersResponse с полями failed_user_ids и failed_user_details.
  • Методы GetChatMembersByIdsAsync и RemoveChatMemberAsync(..., block).
  • Поля User.IsOfficial, SetWebhookRequest.Version и SetWebhookRequest.SelfSignedCert.
  • Типизированные обёртки событий можно десериализовать напрямую из JSON.

Релиз

  • release.yml публикует GitHub Release как Latest. При ручном запуске это можно отключить параметром latest.
  • Версия поднята до 0.8.0-alpha. Breaking changes перечислены в CHANGELOG.

Ревью

Два независимых read-only ревьюера сверили изменения со схемой max-bot-api-client-go/schema.yaml. Подтверждённые находки исправлены во втором коммите: порядок конвертеров, толерантность к null, reply_keyboard, маппинг обёрток, документация.

Проверки

  • dotnet build -warnaserror
  • dotnet test: 776/776 на net10.0 и на net8.0
  • dotnet format --verify-no-changes
  • dotnet format analyzers --verify-no-changes

Generated by Claude Code

- Every enum carries a snake_case JsonConverter, so models and enums deserialize
  with any JsonSerializerOptions (MessageLinkType failed with default options).
- LinkedMessage.Type, MessageRecipient.ChatType, MarkupElement.Type are enums;
  InlineKeyboardAttachment.Payload is a typed InlineKeyboard; Chat.Participants
  and Image.Photos are typed dictionaries.
- Required schema fields are non-nullable (Message, MessageBody, User, Chat,
  ChatMember, CallbackQuery, typed update wrappers, attachments, Video).
- Add chat buttons, DataAttachment, ModifyMembersResponse,
  GetChatMembersByIdsAsync and RemoveChatMemberAsync(block).
- Release workflow publishes the GitHub release as Latest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013pSNnawFkxH4NpFXTzqjCT
- MaxJsonSerializer.Options: UpdateTypeJsonConverter precedes the generic enum
  converter, so unknown update types map to UpdateType.Unknown instead of
  failing GET /subscriptions.
- Required fields tolerate an explicit JSON null (0, empty string, new object).
- reply_keyboard: ReplyKeyboardAttachment, ReplyKeyboardButton and
  AttachmentRequest.ReplyKeyboard; unknown attachments become UnknownAttachment
  with the raw JSON instead of an empty DocumentAttachment.
- Typed update wrappers are JSON-mapped; BotAddedUpdate.InviterId and
  DialogMuted/Unmuted IsMuted are derived; Update.IsChatInferred is public.
- Typed VideoUrls and UpdateChatRequest.Icon; add User.IsOfficial,
  SetWebhookRequest.Version/SelfSignedCert, Subscription.SelfSignedCert.
- Fix docs and changelog wording and footer links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013pSNnawFkxH4NpFXTzqjCT
@CrazyAngelm
CrazyAngelm merged commit 60f09b2 into main Oct 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants