> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ariacompute.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Router 配置校验接口

> 根据咏唱引擎 ROUTER 的 schema 校验原始 YAML 或 JSON 配置。不会改动任何配置。

使用校验接口在应用之前检查一份拟定的 router 配置是否格式良好。可提交原始 YAML 字符串或 JSON 配置对象。该接口返回一个布尔有效性标志，以及（若有）带有路径的 schema 错误列表。不会修改任何实时配置。

这在 CI 流水线与管理面板中非常有用，可防止无效配置的滚动发布。

## 接口

```http theme={null}
POST /v1/router/validate
```

## 认证

使用会话 Cookie 认证，或携带 `Authorization: Bearer <api-key>`。

## 请求体

<ParamField body="config" type="string" required>
  原始 YAML v0.3 配置字符串。
</ParamField>

或

<ParamField body="config" type="object" required>
  匹配 router 配置 schema 的 JSON 对象。
</ParamField>

## 响应

<ResponseField name="valid" type="boolean">
  提交的配置是否通过 schema 校验。
</ResponseField>

<ResponseField name="errors" type="array">
  校验错误列表。`valid` 为 `true` 时为空。

  <Expandable title="items">
    <ResponseField name="path" type="string">
      指向无效字段的点号路径。
    </ResponseField>

    <ResponseField name="message" type="string">
      可读的校验消息。
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://router.example.com/v1/router/validate" \
    -H "Authorization: Bearer <api-key>" \
    -H "Content-Type: application/json" \
    -d '{"config":"listeners:\n  - address: 0.0.0.0\n    port: 8080\nproviders: []\nentrypoints: []\nrecipes: []\nglobal: {}"}'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "valid": false,
    "errors": [
      {
        "path": "providers",
        "message": "providers must be a non-empty array"
      }
    ]
  }
  ```
</ResponseExample>
