- 首頁
- API Enriched
- 驗證規格
驗證規格
本文件說明由 api-specs-enriched 專案發佈的驗證規格之結構與內容。
驗證規格將 API 驗證限制條件、預設值及設定元資料整合至單一 JSON 檔案中。此規格由豐富化後的 OpenAPI 規格生成,並與其一同發佈。
發佈位置:docs/specifications/api/validation.json
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "version": "2.1.0", "generated_at": "2026-01-17T12:00:00Z", "source": "api-specs-enriched",
"required_fields": { ... }, "enum_values": { ... }, "constraints": { ... }, "patterns": [ ... ], "conditional_requirements": { ... }, "minimum_configurations": { ... }, "defaults": { ... }, "extensions": { ... }}required_fields
Section titled “required_fields”指定每個資源各操作類型所需的欄位。
{ "required_fields": { "common": { "all_operations": ["metadata.name", "metadata.namespace"] }, "resources": { "origin_pool": { "create": ["metadata.name", "metadata.namespace", "spec.origin_servers", "spec.port"], "update": ["metadata.name", "metadata.namespace"], "minimum_config": ["metadata.name", "metadata.namespace", "spec.origin_servers", "spec.port"] } } }}enum_values
Section titled “enum_values”定義受限制欄位的允許值。
{ "enum_values": { "loadbalancer_algorithm": { "description": "Load balancing algorithm for distributing traffic across origin servers", "values": [ {"value": "ROUND_ROBIN", "description": "Each healthy endpoint selected in round robin order"}, {"value": "LEAST_REQUEST", "description": "Endpoint with fewest active requests selected"}, {"value": "RING_HASH", "description": "Consistent hashing using ring hash of endpoint names"}, {"value": "RANDOM", "description": "Random healthy endpoint selection"}, {"value": "LB_OVERRIDE", "description": "Hash policy inherited from parent load balancer"} ], "default": "ROUND_ROBIN" } }}constraints
Section titled “constraints”類型層級的驗證預設值及基於模式的規則。
{ "constraints": { "type_defaults": { "string": {"minLength": 0, "maxLength": 1024}, "integer": {"minimum": 0, "maximum": 2147483647} } }}patterns
Section titled “patterns”基於欄位名稱模式的驗證規則,並附有信心分數。
{ "patterns": [ { "pattern": "\\bport$", "constraints": {"minimum": 1, "maximum": 65535}, "confidence": 0.99, "description": "Valid TCP/UDP port range" }, { "pattern": "\\bname$", "constraints": { "minLength": 1, "maxLength": 63, "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" }, "confidence": 0.90, "description": "Kubernetes-style naming convention" } ]}defaults
Section titled “defaults”所有預設值依資源類型整理於統一結構中。
{ "defaults": { "description": "All default values organized by resource type", "resources": { "healthcheck": { "server_applied": { "jitter": 0, "jitter_percent": 0 }, "recommended": { "timeout": 3, "interval": 15, "unhealthy_threshold": 1, "healthy_threshold": 3, "jitter_percent": 30 }, "oneof_recommended": { "health_check": "http_health_check" }, "nested_recommended": { "http_health_check": { "path": "/", "use_http2": false, "expected_status_codes": ["200"], "use_origin_server_name": {} } } }, "origin_pool": { "server_applied": { "no_tls": {}, "healthcheck": [], "loadbalancer_algorithm": "ROUND_ROBIN", "endpoint_selection": "DISTRIBUTED" }, "recommended": { "port": 443, "connection_timeout": 2000, "http_idle_timeout": 300000 }, "advanced_options": { "connection_timeout": 2000, "http_idle_timeout": 300000, "same_as_endpoint_port": {}, "default_circuit_breaker": {}, "disable_outlier_detection": {} }, "oneof_choices": { "port_choice": "port", "tls_choice": "no_tls", "circuit_breaker_choice": "default_circuit_breaker" }, "ui_vs_server": { "loadbalancer_algorithm": { "ui_default": "LB_OVERRIDE", "server_default": "ROUND_ROBIN", "note": "UI preselects LB_OVERRIDE but server applies ROUND_ROBIN if omitted" } } }, "app_firewall": { "server_applied": { "allow_all_response_codes": {}, "default_anonymization": {}, "monitoring": {} } } } }}| 類別 | 說明 | 來源 |
|---|---|---|
server_applied | 欄位省略時 API 套用的值 | 即時 API 測試 |
recommended | F5 XC 網頁主控台預先填入的值 | UI 分析 |
advanced_options | advanced_options 物件內的巢狀預設值 | API 探索 |
oneof_choices | 預設 OneOf 變體選擇 | API 行為 |
oneof_recommended | 建議的 OneOf 變體 | 主控台預設值 |
nested_recommended | 巢狀結構描述的建議值 | UI 分析 |
ui_vs_server | UI 預設值與 API 預設值不同的情況 | 比較分析 |
conditional_requirements
Section titled “conditional_requirements”互斥欄位及條件式相依性。
{ "conditional_requirements": { "resources": { "healthcheck": { "mutually_exclusive": [ { "fields": ["spec.http_health_check", "spec.tcp_health_check", "spec.udp_icmp_health_check"], "reason": "Choose exactly one health check type" } ], "conditional": [] } } }}minimum_configurations
Section titled “minimum_configurations”最小可行設定及可運作範例。
{ "minimum_configurations": { "resources": { "origin_pool": { "description": "Backend origin servers for load balancing", "example": { "metadata": {"name": "backend-pool", "namespace": "default"}, "spec": { "origin_servers": [{"public_name": {"dns_name": "backend1.example.com"}}], "port": 8080 } } } } }}OpenAPI 擴充功能對應
Section titled “OpenAPI 擴充功能對應”豐富化後的 OpenAPI 規格使用以下擴充功能嵌入驗證元資料:
| 擴充功能 | 用途 | 位置 |
|---|---|---|
x-f5xc-required-for | 特定情境的必要欄位 | 結構描述屬性 |
x-f5xc-server-default | 標記伺服器套用的預設值 | 結構描述屬性 |
x-f5xc-recommended-value | 建議的預設值 | 結構描述屬性 |
x-f5xc-recommended-oneof-variant | 建議的 OneOf 變體 | 結構描述定義 |
x-f5xc-conditions | 條件式需求 | 結構描述屬性 |
x-f5xc-minimum-configuration | 最小設定範例 | 結構描述定義 |
x-f5xc-validation | 探索衍生的限制條件 | 結構描述屬性 |
發佈 URL
Section titled “發佈 URL”| 來源 | URL |
|---|---|
| GitHub Pages | https://f5-sales-demo.github.io/api-specs-enriched/specifications/api/validation.json |
| Raw GitHub | https://raw.githubusercontent.com/f5-sales-demo/api-specs-enriched/main/docs/specifications/api/validation.json |
執行管線後:docs/specifications/api/validation.json
驗證規格於 version 欄位中遵循語意化版本規範:
| 變更類型 | 版本遞增 | 範例 |
|---|---|---|
| 重大結構變更 | 主版本號 | 欄位重新命名、章節移除 |
| 新增驗證規則或資源 | 次版本號 | 新增資源預設值 |
| 錯誤修正或說明更新 | 修訂號 | 錯字更正 |
調和優先順序
Section titled “調和優先順序”當多個來源提供限制條件時,調和優先順序為:
- 現有 - 原始 OpenAPI 規格中的限制條件(最高優先順序)
- 探索 - 來自即時 API 探索的限制條件
- 推斷 - 來自模式比對的限制條件(最低優先順序)
- Healthcheck Enhancements - 健康檢查結構描述豐富化
- Origin Pool Enhancements - 來源集區結構描述豐富化
- CLAUDE.md - AI 助理說明
- DEVELOPMENT.md - 開發人員指南
| 版本 | 日期 | 變更內容 |
|---|---|---|
| 2.1.2 | 2026-01-18 | 改寫為純 API 參考;新增 oneof_recommended 及 nested_recommended 類別 |
| 2.1.0 | 2026-01-18 | 統一預設值結構,取代原有分散的各節 |
| 2.0.0 | 2026-01-15 | 初始驗證規格 |