Add JSON schema support
This commit is contained in:
@@ -5,6 +5,7 @@ sing-box uses JSON for configuration files.
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://sing-box.sagernet.org/schema.json",
|
||||
"log": {},
|
||||
"dns": {},
|
||||
"ntp": {},
|
||||
@@ -25,6 +26,7 @@ sing-box uses JSON for configuration files.
|
||||
|
||||
| Key | Format |
|
||||
|----------------|---------------------------------|
|
||||
| `$schema` | [JSON Schema](./schema/) |
|
||||
| `log` | [Log](./log/) |
|
||||
| `dns` | [DNS](./dns/) |
|
||||
| `ntp` | [NTP](./ntp/) |
|
||||
|
||||
@@ -5,6 +5,7 @@ sing-box 使用 JSON 作为配置文件格式。
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://sing-box.sagernet.org/schema.json",
|
||||
"log": {},
|
||||
"dns": {},
|
||||
"ntp": {},
|
||||
@@ -25,6 +26,7 @@ sing-box 使用 JSON 作为配置文件格式。
|
||||
|
||||
| Key | Format |
|
||||
|----------------|------------------------|
|
||||
| `$schema` | [JSON Schema](./schema/) |
|
||||
| `log` | [日志](./log/) |
|
||||
| `dns` | [DNS](./dns/) |
|
||||
| `ntp` | [NTP](./ntp/) |
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "Since sing-box 1.14.0"
|
||||
|
||||
# JSON Schema
|
||||
|
||||
sing-box provides a JSON Schema Draft 2020-12 for configuration files.
|
||||
Compatible editors can use it for completion and validation.
|
||||
|
||||
### Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://sing-box.sagernet.org/schema.json"
|
||||
}
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
#### $schema
|
||||
|
||||
The schema URI used by compatible editors.
|
||||
This field does not affect sing-box runtime behavior.
|
||||
|
||||
The schema published with this documentation is available at
|
||||
[sing-box.sagernet.org/schema.json](https://sing-box.sagernet.org/schema.json).
|
||||
|
||||
### Generate
|
||||
|
||||
Use the following command to generate a schema matching the installed binary:
|
||||
|
||||
```bash
|
||||
sing-box schema -o schema.json
|
||||
```
|
||||
|
||||
Without `--output`, the schema is written to standard output.
|
||||
The generated schema reflects the features included in the current build.
|
||||
|
||||
You can then reference the local schema from a configuration file:
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "./schema.json"
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "自 sing-box 1.14.0 起"
|
||||
|
||||
# JSON Schema
|
||||
|
||||
sing-box 为配置文件提供 JSON Schema Draft 2020-12。
|
||||
兼容的编辑器可使用它提供补全和校验。
|
||||
|
||||
### 结构
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://sing-box.sagernet.org/schema.json"
|
||||
}
|
||||
```
|
||||
|
||||
### 字段
|
||||
|
||||
#### $schema
|
||||
|
||||
兼容编辑器使用的 Schema URI。
|
||||
该字段不影响 sing-box 的运行行为。
|
||||
|
||||
随本文档发布的 Schema 位于
|
||||
[sing-box.sagernet.org/schema.json](https://sing-box.sagernet.org/schema.json)。
|
||||
|
||||
### 生成
|
||||
|
||||
使用以下命令生成与已安装的二进制文件匹配的 Schema:
|
||||
|
||||
```bash
|
||||
sing-box schema -o schema.json
|
||||
```
|
||||
|
||||
未指定 `--output` 时,Schema 将写入标准输出。
|
||||
生成的 Schema 会反映当前构建中包含的功能。
|
||||
|
||||
之后可从配置文件中引用本地 Schema:
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "./schema.json"
|
||||
}
|
||||
```
|
||||
+17317
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user