Skip to content

🟡 [Medium Priority] OpenAPI 验证约束缺失 - vni-id 字段 #10

@xgopilot

Description

@xgopilot

优先级

🟡 中优先级

问题描述

OpenAPI schema 未指定 vni-id 字段必须大于 0。API 消费者可能尝试设置 VNI 为 0,但会被后端拒绝,导致混淆和错误。

影响范围

API 使用体验:

  • API 文档不完整
  • 客户端无法在发送前验证
  • 错误反馈延迟到运行时

相关代码位置

  • 文件: api/v1/openapi.yaml:1252
  • 后端验证: pkg/endpoint/api/endpoint_api_manager.go:589 (检查 VNI != 0)
  • PR: 7niu v1.19.0 rc.1 #6

当前状态

建议的解决方案

在 OpenAPI schema 中添加验证约束:

vni-id:
  type: integer
  format: int64
  minimum: 1  # 添加此行
  maximum: 16777215  # 可选:24-bit VXLAN 上限
  description: |
    Virtual Network Identifier for native VPC mode. Must be a positive 
    non-zero integer. When set, IP conflict detection will consider both 
    VNI and IP address together, allowing endpoints with overlapping IPs 
    in different VPCs.

相关文件

  • api/v1/models/endpoint_change_request.go
  • api/v1/server/embedded_spec.go

相关链接


此 issue 由 PR #6 code review 自动生成

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions