# API Doc Openapi Authoring

> Implements API documentation basics: OpenAPI authoring, Swagger UI/Redoc serving, and first docs build. Use when authoring or serving OpenAPI specs. Don't use for docs-site architecture (see api-doc-site-architecture) or generated SDK docs (see api-documentation-generator).

- Skill: `opknock/api-doc-openapi-authoring` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-doc-openapi-authoring`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-doc-openapi-authoring/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-doc-openapi-authoring

---


Implements API documentation basics: OpenAPI authoring, Swagger UI/Redoc serving, and first docs build. Use when authoring or serving OpenAPI specs. Don't use for docs-site architecture (see api-doc-site-architecture) or generated SDK docs (see api-documentation-generator).

## Agentic Workflow: Read -> Reason -> Act (api-doc-openapi-authoring)

You are **Api Doc Openapi Authoring** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — backend context for `api-doc-openapi-authoring`
- Domain: Implements API documentation basics: OpenAPI authoring, Swagger UI/Redoc serving, and first docs build. Use when authoring or serving OpenAPI specs. Don't use for docs-site architecture (see api-doc-s
- **openapi-authoring**: Author and validate OpenAPI specs by hand or from code — `npm install -g swagger-cli`
- **ui-serving**: Serve Swagger UI and Redoc locally and in production — `npm install -g redoc-cli`
- Check `knowledge` and `prerequisites: swagger-cli, redoc-cli, openapi-generator`

### 2. Reason — think for `api-doc-openapi-authoring`
- For `openapi-authoring`: Author and validate OpenAPI specs by hand or from code — decide which checks to run
- For `ui-serving`: Serve Swagger UI and Redoc locally and in production — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-doc-openapi-authoring` tools
- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Swagger-cli` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-doc-openapi-authoring:7df4ec02`

# API Doc (Implementation)

Gets documentation on its feet: a validated spec and a served UI.

## When to Use
- No docs exist yet
- Quick reference docs for a service
- Single-spec documentation

## Real Commands

```bash
# Validate
npm install -g swagger-cli
swagger-cli validate openapi.yaml

# Bundle for distribution
swagger-cli bundle openapi.yaml -o bundled.yaml

# Serve Redoc
npm install -g redoc-cli
redoc-cli serve openapi.yaml -p 8090

# Build static HTML
redoc-cli build openapi.yaml -o index.html

# Swagger UI
npm install swagger-ui-dist
```

## Minimal Spec

```yaml
openapi: 3.0.0
info:
  title: My API
  version: 1.0.0
paths: {}
```

## Testing
Validate after every spec edit; keep bundled.yaml committed.

## Best Practices
- Validate in pre-commit
- Serve the same bundled file in all environments

## Capabilities

### openapi-authoring
Author and validate OpenAPI specs by hand or from code

**Parameters:**
- `spec` (string): OpenAPI spec path
- `output` (string): Bundled output path

**Commands:**
- `npm install -g swagger-cli`
- `swagger-cli validate openapi.yaml`
- `swagger-cli bundle openapi.yaml -o bundled.yaml`
- `swagger-cli dereference openapi.yaml -o deref.yaml`
- `node -e "const s={openapi:'3.0.0',info:{title:'API',version:'1.0.0'},paths:{}};console.log(JSON.stringify(s,null,2))"`

**Examples:**
- swagger-cli validate openapi.yaml
- swagger-cli bundle openapi.yaml -o bundled.yaml && swagger-cli validate bundled.yaml
- node -e "const s={openapi:'3.0.0',info:{title:'API',version:'1.0.0'},paths:{}};console.log(JSON.stringify(s,null,2))"

### ui-serving
Serve Swagger UI and Redoc locally and in production

**Parameters:**
- `port` (string): Serve port
- `spec` (string): Spec path

**Commands:**
- `npm install -g redoc-cli`
- `redoc-cli serve openapi.yaml`
- `redoc-cli build openapi.yaml -o index.html`
- `npm install swagger-ui-dist`
- `node -e "const d=require('swagger-ui-dist');console.log(d.getAbsoluteFSPath())"`

**Examples:**
- redoc-cli serve openapi.yaml -p 8090
- redoc-cli build openapi.yaml -o index.html
- node -e "const d=require('swagger-ui-dist');console.log(d.getAbsoluteFSPath())"

## References
- [swagger-cli](https://github.com/APIDevTools/swagger-cli)
- [Redoc CLI](https://github.com/Redocly/redoc/blob/master/cli/README.md)

