The interface is localized. Skill descriptions and documents are machine-translated by AI into your language; code, commands, paths and technical terms stay in the original, and the author's document governs.
Design serialization schemas using JSON Schema, Protocol Buffer definitions, or Apache Avro. Covers schema versioning, backwards compatibility, validation rules, and evolution strategies for long-lived data formats. Use when defining a new API contract or data interchange format, adding fields to an existing schema without breaking consumers, migrating betw…
Independent GitHub snapshot · Automated classification · Original documentation governs
name: design-serialization-schema
locale: wenyan-lite
source_locale: en
source_commit: 82c77053
fence_basis_commit: 82c77053
translator: "Julius Brussee homage — caveman"
translation_date: "2026-04-24"
description: >
Design serialization schemas using JSON Schema, Protocol Buffer definitions,
or Apache Avro. Covers schema versioning, backwards compatibility, validation
rules, and evolution strategies for long-lived data formats. Use when defining
a new API contract or data interchange format, adding fields to an existing
schema without breaking consumers, migrating between schema versions, choosing
between schema systems, or documenting data validation rules for automated
enforcement.
license: MIT
allowed-tools: Read Write Edit Bash Grep Glob
metadata:
author: Philipp Thoss
version: "1.0"
domain: data-serialization
complexity: intermediate
language: multi
tags: json-schema, protobuf, avro, schema-evolution, versioning, compatibility
設計序列化模式
建版本良好之序列化模式,俾其演化不傷使用者。
適用時機
定新 API 合約或數據交換格式
於既有模式增欄位而不傷使用者
於模式版本之間遷移
擇模式系統(JSON Schema、Protobuf、Avro)
錄數據驗證規則以便自動執行
輸入
必要:數據模型(實體關係、欄位類型、約束)
必要:相容要求(誰消費此數據、舊格式須讀多久)
選擇:待演化之既有模式
選擇:性能要求(驗證速度、模式註冊中心整合)
選擇:目標序列化格式(JSON、二進、欄式)
步驟
步驟一:擇模式系統
System
Format
Strengths
Best For
JSON Schema
JSON
Widely supported, flexible validation
REST APIs, config validation
Protocol Buffers
Binary
Compact, fast, strong typing, built-in evolution
gRPC, microservices
Apache Avro
Binary/JSON
Schema in data, excellent evolution support
Kafka, data pipelines
XML Schema (XSD)
XML
Comprehensive typing, namespace support
Enterprise/legacy SOAP
TypeBox/Zod
TypeScript
Type inference, runtime validation
TypeScript APIs
預期: 依生態、性能、演化需求擇定模式系統。
失敗時: 若未決,自 JSON Schema 始——工具支援最廣,可層疊於既有 JSON API 之上。
# Measurement Schema (v1)
## Overview
Represents a single sensor reading with metadata.
## Fields
| Field | Type | Required | Description | Constraints |
|-------|------|----------|-------------|-------------|
| sensor_id | string | Yes | Unique sensor ID | Pattern: `^[a-z]+-[0-9]+
design-serialization-schema · Skills-SI Market
|
| value | number | Yes | Measured value | Any valid IEEE 754 double |
| unit | enum | Yes | Unit of measurement | One of: celsius, fahrenheit, kelvin, percent, ppm |
| timestamp | string | Yes | Reading time | ISO 8601 with timezone |
| metadata | object | No | Key-value pairs | String keys and values |
## Changelog
| Version | Date | Changes |
|---------|------|---------|
| v1 | 2025-03-01 | Initial schema |
## Compatibility
- **Backwards**: Consumers of v1 will continue to work with future versions
- **Policy**: Only additive, optional field changes between minor versions
預期: 文檔自動生成或與模式定義同步。
失敗時: 文檔與模式偏離時,加 CI 檢查以對照模式原本驗證之。