|
| 1 | +--- |
| 2 | +name: openapi-format |
| 3 | +description: Configure and run openapi-format CLI workflows for OpenAPI/AsyncAPI documents. Use when you need to sort fields, filter operations/tags/flags/content, change casing, generate operationIds, apply overlays, convert OpenAPI versions (3.0/3.1 to 3.1/3.2), rename titles, split specs, bundle refs, or manage .openapiformatrc/--configFile driven formatting pipelines with minimal config overrides. |
| 4 | +--- |
| 5 | + |
| 6 | +# openapi-format |
| 7 | + |
| 8 | +Follow this skill when a user asks to transform an OpenAPI document with the `openapi-format` CLI. |
| 9 | + |
| 10 | +## Core workflow |
| 11 | + |
| 12 | +1. Identify the target outcome first. |
| 13 | +- Determine exactly what should change: order, filtering, casing, generation, overlay, conversion, rename, output format, split. |
| 14 | +- Determine input source (local file, remote URL, or overlay `extends` fallback). |
| 15 | + |
| 16 | +2. Choose command shape. |
| 17 | +- Prefer a single command with explicit input/output unless the user asks for stdout. |
| 18 | +- Use `--configFile` for reusable workflows. |
| 19 | +- Use `.openapiformatrc` for project defaults. |
| 20 | + |
| 21 | +3. Keep config minimal. |
| 22 | +- Start from defaults. |
| 23 | +- Add only keys required for requested behavior. |
| 24 | +- Avoid writing exhaustive config unless requested. |
| 25 | + |
| 26 | +4. Apply correct precedence. |
| 27 | +- Load `.openapiformatrc` only when `--configFile` is not supplied. |
| 28 | +- Load and merge `--configFile` values. |
| 29 | +- Apply CLI options last. |
| 30 | +- Normalize `--no-sort` and `--no-bundle` into `sort=false` and `bundle=false`. |
| 31 | + |
| 32 | +5. Respect processing order. |
| 33 | +- `generate -> filter -> overlay -> sort -> casing -> convertTo -> rename -> write/split/stdout` |
| 34 | + |
| 35 | +6. Produce the output safely. |
| 36 | +- Use `--output` for file writes. |
| 37 | +- If `--split` is true, require `--output` and treat it as split target root. |
| 38 | +- Use `--json` or `--yaml` for stdout output formatting. |
| 39 | + |
| 40 | +## Decision rules |
| 41 | + |
| 42 | +### Filter semantics |
| 43 | +- Treat `methods`, `tags`, `operationIds`, `operations`, `flags`, `flagValues`, `responseContent`, and `requestContent` as removal filters. |
| 44 | +- Treat `inverseMethods`, `inverseTags`, `inverseOperationIds`, `inverseFlags`, `inverseFlagValues`, `inverseResponseContent`, and `inverseRequestContent` as keep filters. |
| 45 | +- Use `unusedComponents` to remove unreferenced components recursively (iterative cleanup). |
| 46 | +- Use `stripFlags` to delete marker fields after filtering. |
| 47 | + |
| 48 | +### Overlay behavior |
| 49 | +- Accept `--overlayFile` with `actions`. |
| 50 | +- If input file is omitted and overlay has `extends`, use `extends` as effective input. |
| 51 | +- Resolve local `extends` relative to overlay file directory. |
| 52 | + |
| 53 | +### Sorting and components |
| 54 | +- Default sorting comes from `defaultSort.json`. |
| 55 | +- `sortPathsBy` controls path ordering (`original`, `path`, `tags`). |
| 56 | +- `--sortComponentsFile` controls which component groups are alphabetized. |
| 57 | +- `--sortComponentsProps` alphabetizes schema properties in `components.schemas.*.properties`. |
| 58 | + |
| 59 | +### Output constraints |
| 60 | +- `--split` requires `--output`. |
| 61 | +- `--keepComments` only affects YAML comment preservation. |
| 62 | +- `--lineWidth` controls YAML line wrapping (`-1` means unlimited). |
| 63 | + |
| 64 | +## Use references |
| 65 | + |
| 66 | +Open only what is needed: |
| 67 | +- `references/feature-matrix.md` for option behavior, defaults, and interactions. |
| 68 | +- `references/config-patterns.md` for minimal config templates. |
| 69 | +- `references/command-recipes.md` for runnable command patterns. |
| 70 | +- `references/troubleshooting.md` for failure diagnosis and fixes. |
| 71 | + |
| 72 | +## Delivery checklist |
| 73 | + |
| 74 | +1. Return the exact command(s) to run. |
| 75 | +2. Return minimal config file contents if config files are needed. |
| 76 | +3. Explain expected transformation result in plain terms. |
| 77 | +4. Call out side effects (component pruning, split output tree, version conversion changes). |
| 78 | +5. Highlight any assumptions (input path, output path, format, bundle behavior). |
0 commit comments