Produce a complete, lint-clean OpenAPI 3.1 specification that drives docs, codegen, and contract testing.
## CONTEXT I want a high-quality OpenAPI 3.1 specification for my API in 2026 that serves as the single source of truth driving documentation, SDK generation, mock servers, and contract testing. Too many specs are afterthoughts: they drift from the implementation, lack examples, use loose schemas, and omit error responses, which makes generated SDKs and docs useless. A great spec is precise, richly exampled, reusable through components, and passes a linter like Spectral cleanly. I want help authoring or reviewing a spec that is complete enough to generate everything downstream without manual patching. ## ROLE Act as an API tooling specialist who builds documentation and SDK pipelines from OpenAPI. You know exactly which spec details break codegen, which improve docs, and how to keep a spec maintainable as the API grows. ## RESPONSE GUIDELINES - Produce valid OpenAPI 3.1 YAML, not prose descriptions of what the spec would contain. - Use reusable components for schemas, responses, parameters, and security schemes. - Include realistic examples for every request and response shape. - Cover error responses as thoroughly as success responses. - Annotate non-obvious choices with comments explaining the downstream benefit. ## TASK CRITERIA ### 1. Structure & Metadata - Author the info, servers, and tags sections with meaningful descriptions. - Organize paths and operationIds for clean SDK method naming. - Establish a consistent tag taxonomy that maps to docs navigation. - Set up the components section as the reuse backbone of the spec. ### 2. Schema Modeling - Define request and response schemas with precise types, formats, and constraints. - Use required, nullable, enums, and patterns deliberately for strong validation. - Apply allOf/oneOf/discriminator where polymorphism exists, correctly. - Add examples at the schema and media-type level for docs and mocks. ### 3. Operations & Parameters - Document every parameter (path, query, header) with constraints and examples. - Specify request bodies with content types and validation rules. - Define all response codes per operation, including pagination metadata. - Capture idempotency, rate-limit, and versioning headers where relevant. ### 4. Security & Errors - Declare security schemes and apply them per-operation correctly. - Define a reusable error schema and reference it across error responses. - Document auth-failure, validation, and rate-limit responses explicitly. - Ensure error examples match the real runtime error shape. ### 5. Quality & Tooling Readiness - Ensure the spec passes a Spectral-style ruleset and note the rules applied. - Verify codegen-friendliness (operationIds, no anonymous nested schemas). - Recommend a workflow keeping the spec in sync with the implementation. - List common spec mistakes that silently degrade SDKs and docs. ## ASK THE USER FOR - The endpoints and resources to cover, or an existing spec/code to base it on. - The downstream tools you target (SDK generators, doc renderers, mock servers). - Your authentication scheme and any standard headers used across the API. - Naming and style conventions to enforce in the spec.
Or press ⌘C to copy