openapi-design
Best practices for OpenAPI-first API design, linting, versioning, and code generation.
Works with
--- name: openapi-design description: Best practices for OpenAPI-first API design, linting, versioning, and code generation. license: MIT --- # OpenAPI Design Purpose: Ensure consistent, versioned API contracts suitable for code generation, client integration, and CI gating. Overview - Favor contract-first design: write or finalize the OpenAPI YAML/JSON before implementing controllers. - Keep OperationIDs stable and descriptive; they drive codegen and client SDK method names. Tools (examples) - Linting/validation: `@stoplight/spectral` (Spectral), `openapi-cli`, `oas-validator` - Generation: `openapi-generator-cli` or `openapi-generator` Docker image - Local checks: `ajv` for JSON Schema example validation, `yamllint` for formatting - CI: run Spectral + generator + compile step as gating checks Key topics & guidance - Contract-first design and stable `operationId`s: prefer semantic, version-proof names. - Security schemes: model JWT/OAuth2/mTLS explicitly under `components/securitySchemes` and attach to operations. - Linting + automated validation: add Spectral ruleset for project conventions; fail CI on lint errors. - Versioning: support `major.minor` in API path or header; document breaking changes in changelog. - Codegen templates: keep generator templates in `.github/templates/openapi/` and pin generator version. Required inputs - Product/feature API requirements (endpoints, payloads, auth expectations) - Example request/response payloads (JSON fixtures) to validate schemas Outputs - A linted OpenAPI file (`openapi.yaml` or `openapi.json`) - Contract-change checklist to attach to PRs - Codegen configuration (generator args, template overrides) Quick checklist (PR / author) - Add or update `openapi.yaml` in `specs/` or feature folder - Run: `npx @stoplight/spectral lint specs/openapi.yaml` - Run generator smoke: `openapi-generator-cli generate -i specs/openapi.yaml -g spring -o build/generated` then compile the generated module - Include JSON example files and run schema validation: `node ./scripts/validate-examples.js specs/openapi.yaml examples/` - Update changelog with contract changes and migration notes CI snippet (example) ```yaml - name: Lint OpenAPI run: npx @stoplight/spectral lint specs/openapi.yaml --ruleset .spectral.yml - name: Generate and build scaffold run: | openapi-generator-cli generate -i specs/openapi.yaml -g spring -o build/generated --skip-validate-spec pushd build/generated && mvn -q -DskipTests package || exit 1 ``` Contract change policy - Small, additive changes (non-breaking) may be approved with normal PR flow. - Breaking changes require: migration notes, version bump, consumer notification, and feature-flag/compatibility layer when possible. - Add a `contract-change.md` file for any breaking change detailing affected consumers and rollout plan. Example generator command ``` openapi-generator-cli generate \ -i specs/openapi.yaml \ -g spring \ -o modules/generated-control-plane \ --additional-properties=java8=true,library=spring-boot ``` Common pitfalls - Generating code directly into main source directories (use `build/generated` or separate module). - Relying on default generator templates — customize to align with project conventions. - Missing example fixtures — use `examples/` to validate schemas. PR reviewer checklist - Spectral lint passes and any custom rules satisfied - Example requests/responses validate against the schema - Security schemes and scopes documented and applied to operations - Generated code compiles and basic smoke tests included or referenced Training resources - Spectral linting: https://meta.stoplight.io/docs/spectral - OpenAPI Generator: https://openapi-generator.tech/docs/usage - Contract-first API design patterns (internal or general articles) Success criteria - OpenAPI lints clean in CI with project ruleset - Generated scaffold compiles and basic smoke tests pass in CI - Contract-change checklist attached to PR for any non-trivial changes
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 时使用。

