json-schema-lookup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

JSON Schema Lookup via SchemaStore

通过SchemaStore查找JSON Schema

Query schemastore.org's catalog of public configuration file schemas to validate structure, discover options, and check allowed values.
查询schemastore.org的公开配置文件schema目录,以验证结构、探索可用选项并检查允许的值。

API

API

  • Catalog:
    https://www.schemastore.org/api/json/catalog.json
    • Structure:
      { "schemas": [{ "name", "description", "fileMatch", "url", "versions"? }] }
  • Individual schemas: Fetch the
    url
    from the matching catalog entry
  • 目录
    https://www.schemastore.org/api/json/catalog.json
    • 结构:
      { "schemas": [{ "name", "description", "fileMatch", "url", "versions"? }] }
  • 单个schema:从匹配的目录条目中获取对应的
    url

Workflow

工作流程

1. Find the schema

1. 查找schema

Search the catalog by name or filename pattern:
bash
undefined
通过名称或文件名模式搜索目录:
bash
undefined

Search by name (case-insensitive)

按名称搜索(不区分大小写)

curl -s https://www.schemastore.org/api/json/catalog.json | jq '.schemas[] | select(.name | test("tsconfig"; "i")) | {name, url, fileMatch}'
curl -s https://www.schemastore.org/api/json/catalog.json | jq '.schemas[] | select(.name | test("tsconfig"; "i")) | {name, url, fileMatch}'

Search by filename match

按文件名匹配搜索

curl -s https://www.schemastore.org/api/json/catalog.json | jq '.schemas[] | select(.fileMatch[]? | test("package\.json")) | {name, url}'

Alternatively, use WebFetch on the catalog URL and ask for the relevant entry.
curl -s https://www.schemastore.org/api/json/catalog.json | jq '.schemas[] | select(.fileMatch[]? | test("package\.json")) | {name, url}'

或者,对目录URL使用WebFetch并请求相关条目。

2. Fetch and inspect the schema

2. 获取并查看schema

bash
undefined
bash
undefined

List top-level properties

列出顶层属性

curl -s SCHEMA_URL | jq '.properties | keys'
curl -s SCHEMA_URL | jq '.properties | keys'

Inspect a specific field (type, enum values, description)

查看特定字段(类型、枚举值、描述)

curl -s SCHEMA_URL | jq '.properties.FIELD_NAME'
curl -s SCHEMA_URL | jq '.properties.FIELD_NAME'

Check definitions/shared types (schemas use $ref to these)

查看定义/共享类型(schema使用$ref引用这些)

curl -s SCHEMA_URL | jq '.definitions.DEF_NAME.properties'
curl -s SCHEMA_URL | jq '.definitions.DEF_NAME.properties'

Get the full schema (warning - might be large!)

获取完整schema(注意:文件可能很大!)

curl -s SCHEMA_URL | jq .
undefined
curl -s SCHEMA_URL | jq .
undefined

3. Common queries

3. 常见查询

bash
undefined
bash
undefined

Find enum values for a field

查找字段的枚举值

curl -s SCHEMA_URL | jq '.properties.FIELD.enum'
curl -s SCHEMA_URL | jq '.properties.FIELD.enum'

List nested properties (e.g. compilerOptions in tsconfig)

列出嵌套属性(例如tsconfig中的compilerOptions)

curl -s SCHEMA_URL | jq '.definitions.compilerOptionsDefinition.properties.compilerOptions.properties | keys'
curl -s SCHEMA_URL | jq '.definitions.compilerOptionsDefinition.properties.compilerOptions.properties | keys'

Find all required fields

查找所有必填字段

curl -s SCHEMA_URL | jq '.required'
undefined
curl -s SCHEMA_URL | jq '.required'
undefined

Tips

提示

  • Some schemas use
    allOf
    /
    anyOf
    composition -- check those arrays for the full property set
  • The
    versions
    field on catalog entries provides version-specific schema URLs when available
  • Schema URLs vary: some point to
    json.schemastore.org
    , others to
    raw.githubusercontent.com
  • For large schemas, query specific paths rather than dumping the entire document
  • Cache the catalog response locally if making multiple lookups in one session
  • 部分schema使用
    allOf
    /
    anyOf
    组合方式——请检查这些数组以获取完整的属性集合
  • 目录条目中的
    versions
    字段会在可用时提供特定版本的schema URL
  • Schema URL各不相同:有些指向
    json.schemastore.org
    ,有些指向
    raw.githubusercontent.com
  • 对于大型schema,查询特定路径而非导出整个文档
  • 如果在一个会话中进行多次查找,请将目录响应本地缓存