openapi
OpenAPI 3.1 specification, schema design, and code generation. Use when designing REST APIs, generating TypeScript clients, or creating API documentation. Use for openapi, swagger, api-spec, schema, code-generation, api-docs, openapi-typescript, zod-openapi.
Works with
---
name: openapi
description: OpenAPI 3.1 specification, schema design, and code generation. Use when designing REST APIs, generating TypeScript clients, or creating API documentation. Use for openapi, swagger, api-spec, schema, code-generation, api-docs, openapi-typescript, zod-openapi.
license: MIT
---
# OpenAPI
## Overview
OpenAPI Specification (OAS) 3.1 is the industry standard for describing HTTP APIs. It defines a machine-readable contract covering endpoints, request/response schemas, authentication, and error formats. OpenAPI 3.1 is a strict superset of JSON Schema Draft 2020-12, enabling full JSON Schema compatibility for data validation and type generation.
**When to use:** Designing REST APIs, generating typed clients (TypeScript, Python, Go), producing interactive documentation, validating request/response payloads, contract-first API development, API gateway configuration.
**When NOT to use:** GraphQL APIs (use the GraphQL schema), gRPC services (use Protocol Buffers), WebSocket-only protocols, internal function calls that never cross a network boundary.
## Quick Reference
| Pattern | Element | Key Points |
| --------------- | ------------------------------------------------------- | -------------------------------------------------- |
| Document root | `openapi`, `info`, `paths` | `openapi: '3.1.0'` required at top level |
| Path item | `/resources/{id}` | Curly braces for path parameters |
| Operation | `get`, `post`, `put`, `delete`, `patch` | Each operation needs `operationId` and `responses` |
| Parameters | `in: path\|query\|header\|cookie` | Path params are always `required: true` |
| Request body | `requestBody.content` | Keyed by media type (`application/json`) |
| Response | `responses.200.content` | At least one response required per operation |
| Component ref | `$ref: '#/components/schemas/Name'` | Reuse schemas, parameters, responses |
| Schema types | `type: string\|number\|integer\|boolean\|array\|object` | Arrays support `type: ["string", "null"]` in 3.1 |
| Composition | `oneOf`, `anyOf`, `allOf` | Model polymorphism and intersection types |
| Discriminator | `discriminator.propertyName` | Hint for code generators with `oneOf`/`anyOf` |
| Security | `securitySchemes` + top-level `security` | Bearer, API key, OAuth2, OpenID Connect |
| Tags | `tags` on operations | Group operations for documentation |
| Type generation | `openapi-typescript` | Zero-runtime TypeScript types from spec |
| Typed fetch | `openapi-fetch` | Type-safe HTTP client using generated types |
| React Query | `openapi-react-query` | Type-safe React Query hooks from spec |
| Schema-first | `zod-openapi` | Generate OpenAPI documents from Zod schemas |
## Common Mistakes
| Mistake | Correct Pattern |
| ------------------------------------------ | ------------------------------------------------------------------------------ |
| Using `nullable: true` in 3.1 | Use `type: ["string", "null"]` (3.0 syntax removed) |
| Missing `operationId` on operations | Always set unique `operationId` for code generation |
| Path parameter not in `required` | Path parameters are always required (`required: true`) |
| Inline schemas everywhere | Extract to `components/schemas` and use `$ref` |
| `allOf` with conflicting `required` fields | Merge `required` arrays; `allOf` unions them |
| Discriminator without shared property | All schemas in `oneOf`/`anyOf` must include the discriminator property |
| Empty `description` on responses | Every response needs a meaningful `description` |
| Using `type: object` without `properties` | Always define `properties` or use `additionalProperties` |
| Circular `$ref` chains | Break cycles with lazy resolution or restructure schemas |
| Mixing 3.0 and 3.1 syntax | Choose one version; 3.1 drops `nullable`, changes `exclusiveMinimum` to number |
## Delegation
- **API design review**: Use `Task` agent to audit spec completeness and consistency
- **Type generation**: Use `Explore` agent to find project-specific OpenAPI tooling config
- **Code review**: Delegate to `code-reviewer` agent for generated client usage patterns
> If the `typescript-patterns` skill is available, delegate advanced TypeScript typing questions to it.
## References
- [Schema design: paths, operations, parameters, components, and $ref](references/schema-design.md)
- [Data types: formats, composition, discriminators, and nullable](references/data-types.md)
- [Code generation: openapi-typescript, openapi-fetch, openapi-react-query, and Zod OpenAPI](references/code-generation.md)
- [Documentation: Swagger UI, Redoc, and API docs best practices](references/documentation.md)More API Design skills
lark-event
larksuite/cli
Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM messages/reactions/chat changes, Approval status changes, Task updates, VC meeting started/joined/ended, Minutes generated, Whiteboard updated, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses.
lark-contact
larksuite/cli
飞书 / Lark 通讯录:按姓名 / 邮箱解析成 open_id,或按 open_id 反查姓名 / 部门 / 邮箱 / 联系方式 / 个人状态 / 签名,以及按关键词搜索当前用户可见的机器人 / 智能体(agent)。当用户提到一个名字要下一步发消息 / 排日程,或拿到 open_id 想查具体信息时使用。不负责部门树遍历、按部门列员工、组织架构图,这类需求走原生 OpenAPI。
lark-openapi-explorer
larksuite/cli
飞书/Lark 原生 OpenAPI 探索:从官方文档库中挖掘未经 CLI 封装的原生 OpenAPI 接口。当用户的需求无法被现有 lark-* skill 或 lark-cli 已注册命令满足,需要查找并调用原生飞书 OpenAPI 时使用。

