Skip to content

Commit 60258a7

Browse files
committed
feat: Added openapi-format skills
1 parent 492a3cd commit 60258a7

7 files changed

Lines changed: 684 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33

44
.idea
55
.tmp
6+
.agents

readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ With the newly added OpenAPI Overlay support, users can overlay changes onto exi
2626
+ [Local Installation (recommended)](#local-installation-recommended)
2727
+ [Global Installation](#global-installation)
2828
+ [NPX usage](#npx-usage)
29+
+ [Codex skill usage](#codex-skill-usage)
2930
* [Command Line Interface](#command-line-interface)
3031
* [OpenAPI format CLI options](#openapi-format-cli-options)
3132
* [OpenAPI sort configuration options](#openapi-sort-configuration-options)
@@ -139,6 +140,20 @@ To execute the CLI without installing it via npm, use the npx method
139140
$ npx openapi-format your-openapi-file.yaml
140141
```
141142

143+
### Codex skill usage
144+
145+
To install the `openapi-format` skill from this repository:
146+
147+
```shell
148+
$ npx skills add https://github.com/thim81/openapi-format --skill openapi-format
149+
```
150+
151+
Then use it in Codex by explicitly referencing the skill in your prompt, for example:
152+
153+
```text
154+
Using $openapi-format, create a minimal filter config to remove internal endpoints and give me the CLI command.
155+
```
156+
142157
## Command Line Interface
143158

144159
```

skills/openapi-format/SKILL.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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).
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Command recipes
2+
3+
These are direct CLI recipes for common and advanced workflows.
4+
5+
## Basic formatting
6+
7+
```bash
8+
openapi-format openapi.yaml --output openapi.formatted.yaml
9+
```
10+
11+
## Print to stdout as JSON
12+
13+
```bash
14+
openapi-format openapi.yaml --json
15+
```
16+
17+
## Print to stdout as YAML
18+
19+
```bash
20+
openapi-format openapi.json --yaml
21+
```
22+
23+
## Use a specific config file
24+
25+
```bash
26+
openapi-format openapi.yaml --configFile config/format.yaml --output dist/openapi.yaml
27+
```
28+
29+
## Use custom sort file
30+
31+
```bash
32+
openapi-format openapi.yaml --sortFile config/sort.json --output dist/openapi.yaml
33+
```
34+
35+
## Sort specific component groups alphabetically
36+
37+
```bash
38+
openapi-format openapi.yaml --sortComponentsFile config/sort-components.json --output dist/openapi.yaml
39+
```
40+
41+
## Sort schema properties within components
42+
43+
```bash
44+
openapi-format openapi.yaml --sortComponentsProps --output dist/openapi.yaml
45+
```
46+
47+
## Disable sort
48+
49+
```bash
50+
openapi-format openapi.yaml --no-sort --output dist/openapi.yaml
51+
```
52+
53+
## Disable bundling
54+
55+
```bash
56+
openapi-format openapi.yaml --no-bundle --output dist/openapi.yaml
57+
```
58+
59+
## Filter with filter file
60+
61+
```bash
62+
openapi-format openapi.yaml --filterFile config/filter.yaml --output dist/openapi.filtered.yaml
63+
```
64+
65+
## Apply casing rules
66+
67+
```bash
68+
openapi-format openapi.yaml --casingFile config/casing.yaml --output dist/openapi.cased.yaml
69+
```
70+
71+
## Generate operationIds
72+
73+
```bash
74+
openapi-format openapi.yaml --generateFile config/generate.yaml --output dist/openapi.generated.yaml
75+
```
76+
77+
## Apply overlay to input
78+
79+
```bash
80+
openapi-format openapi.yaml --overlayFile config/overlay.yaml --output dist/openapi.overlay.yaml
81+
```
82+
83+
## Apply overlay with `extends` as implicit input
84+
85+
```bash
86+
openapi-format --overlayFile config/overlay.yaml --output dist/openapi.overlay.yaml
87+
```
88+
89+
## Convert to OpenAPI 3.1
90+
91+
```bash
92+
openapi-format openapi.yaml --convertTo 3.1 --output dist/openapi.3.1.yaml
93+
```
94+
95+
## Convert to OpenAPI 3.2
96+
97+
```bash
98+
openapi-format openapi.yaml --convertTo 3.2 --output dist/openapi.3.2.yaml
99+
```
100+
101+
## Rename API title
102+
103+
```bash
104+
openapi-format openapi.yaml --rename "Example API" --output dist/openapi.renamed.yaml
105+
```
106+
107+
## Split into multi-file structure
108+
109+
```bash
110+
openapi-format openapi.yaml --split --output dist/openapi/root.yaml
111+
```
112+
113+
## Preserve YAML comments and set line width
114+
115+
```bash
116+
openapi-format openapi.yaml --keepComments --lineWidth 120 --output dist/openapi.yaml
117+
```
118+
119+
## Verbose diagnostics
120+
121+
```bash
122+
openapi-format openapi.yaml --filterFile config/filter.yaml --output dist/openapi.yaml -vv
123+
```
124+
125+
## Playground share link generation
126+
127+
```bash
128+
openapi-format openapi.yaml --configFile config/format.yaml --playground
129+
```
130+
131+
## Composite example: generate, filter, overlay, casing, convert, rename
132+
133+
```bash
134+
openapi-format openapi.yaml \
135+
--generateFile config/generate.yaml \
136+
--filterFile config/filter.yaml \
137+
--overlayFile config/overlay.yaml \
138+
--casingFile config/casing.yaml \
139+
--convertTo 3.2 \
140+
--rename "Public API" \
141+
--output dist/openapi.public.3.2.yaml
142+
```
143+
144+
Expected processing order is fixed by CLI internals; flags do not reorder stages.

0 commit comments

Comments
 (0)