openapi-format
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseopenapi-format
openapi-format
Follow this skill when a user asks to transform an OpenAPI document with the CLI.
openapi-format当用户要求使用 CLI转换OpenAPI文档时,请遵循本技能。
openapi-formatCore workflow
核心工作流
- Identify the target outcome first.
- Determine exactly what should change: order, filtering, casing, generation, overlay, conversion, rename, output format, split.
- Determine input source (local file, remote URL, or overlay fallback).
extends
- Choose command shape.
- Prefer a single command with explicit input/output unless the user asks for stdout.
- Use for reusable workflows.
--configFile - Use for project defaults.
.openapiformatrc
- Keep config minimal.
- Start from defaults.
- Add only keys required for requested behavior.
- Avoid writing exhaustive config unless requested.
- Apply correct precedence.
- Load only when
.openapiformatrcis not supplied.--configFile - Load and merge values.
--configFile - Apply CLI options last.
- Normalize and
--no-sortinto--no-bundleandsort=false.bundle=false
- Respect processing order.
generate -> filter -> overlay -> sort -> casing -> convertTo -> rename -> write/split/stdout
- Produce the output safely.
- Use for file writes.
--output - If is true, require
--splitand treat it as split target root.--output - Use or
--jsonfor stdout output formatting.--yaml
- 首先确定目标结果。
- 明确需要更改的内容:顺序、过滤、大小写、生成、覆盖、转换、重命名、输出格式、拆分。
- 确定输入源(本地文件、远程URL或覆盖层的回退源)。
extends
- 选择命令形式。
- 优先使用带有明确输入/输出的单个命令,除非用户要求输出到stdout。
- 对于可复用工作流,使用。
--configFile - 对于项目默认配置,使用。
.openapiformatrc
- 保持配置最简。
- 从默认配置开始。
- 仅添加实现所需行为必需的配置项。
- 除非用户要求,否则不要编写详尽的配置。
- 遵循正确的优先级。
- 仅当未提供时,才加载
--configFile。.openapiformatrc - 加载并合并中的配置值。
--configFile - 最后应用CLI选项。
- 将和
--no-sort标准化为--no-bundle和sort=false。bundle=false
- 遵守处理顺序。
生成 -> 过滤 -> 覆盖 -> 排序 -> 大小写修改 -> 版本转换 -> 重命名 -> 写入/拆分/stdout
- 安全生成输出。
- 使用进行文件写入。
--output - 如果为true,则必须指定
--split,并将其视为拆分目标的根目录。--output - 对于stdout输出格式,使用或
--json。--yaml
Decision rules
决策规则
Filter semantics
过滤语义
- Treat ,
methods,tags,operationIds,operations,flags,flagValues, andresponseContentas removal filters.requestContent - Treat ,
inverseMethods,inverseTags,inverseOperationIds,inverseFlags,inverseFlagValues, andinverseResponseContentas keep filters.inverseRequestContent - Use to remove unreferenced components recursively (iterative cleanup).
unusedComponents - Use to delete marker fields after filtering.
stripFlags
- 将、
methods、tags、operationIds、operations、flags、flagValues和responseContent视为移除过滤器。requestContent - 将、
inverseMethods、inverseTags、inverseOperationIds、inverseFlags、inverseFlagValues和inverseResponseContent视为保留过滤器。inverseRequestContent - 使用递归移除未被引用的组件(迭代清理)。
unusedComponents - 使用在过滤后删除标记字段。
stripFlags
Overlay behavior
覆盖层行为
- Accept with
--overlayFile.actions - If input file is omitted and overlay has , use
extendsas effective input.extends - Resolve local relative to overlay file directory.
extends
- 接受带有的
actions。--overlayFile - 如果省略输入文件且覆盖层包含,则将
extends作为有效输入。extends - 相对于覆盖层文件目录解析本地的。
extends
Sorting and components
排序与组件
- Default sorting comes from .
defaultSort.json - controls path ordering (
sortPathsBy,original,path).tags - controls which component groups are alphabetized.
--sortComponentsFile - alphabetizes schema properties in
--sortComponentsProps.components.schemas.*.properties
- 默认排序规则来自。
defaultSort.json - 控制路径排序方式(
sortPathsBy、original、path)。tags - 控制哪些组件组按字母顺序排列。
--sortComponentsFile - 对
--sortComponentsProps中的 schema 属性按字母顺序排列。components.schemas.*.properties
Output constraints
输出约束
- requires
--split.--output - only affects YAML comment preservation.
--keepComments - controls YAML line wrapping (
--lineWidthmeans unlimited).-1
- 必须配合
--split使用。--output - 仅影响YAML注释的保留。
--keepComments - 控制YAML行换行(
--lineWidth表示无限制)。-1
Use references
参考资料
Open only what is needed:
- for option behavior, defaults, and interactions.
references/feature-matrix.md - for minimal config templates.
references/config-patterns.md - for runnable command patterns.
references/command-recipes.md - for failure diagnosis and fixes.
references/troubleshooting.md
仅打开必要的资料:
- :用于查看选项行为、默认值及交互逻辑。
references/feature-matrix.md - :用于获取最简配置模板。
references/config-patterns.md - :用于获取可直接运行的命令示例。
references/command-recipes.md - :用于故障诊断和修复。
references/troubleshooting.md
Delivery checklist
交付检查清单
- Return the exact command(s) to run.
- Return minimal config file contents if config files are needed.
- Explain expected transformation result in plain terms.
- Call out side effects (component pruning, split output tree, version conversion changes).
- Highlight any assumptions (input path, output path, format, bundle behavior).
- 返回要运行的精确命令。
- 如果需要配置文件,返回最简配置文件内容。
- 用通俗易懂的语言解释预期的转换结果。
- 指出副作用(组件修剪、拆分输出目录结构、版本转换变更)。
- 突出任何假设条件(输入路径、输出路径、格式、合并行为)。