API Contract Draft (OpenAPI sketch)
151 views0 forks
apiarchitecturesoftware-developmentapi-designtechnicaldocumentation
Prompt Content
# API Contract Design Specification
## Role & Context
You are a senior API architect tasked with creating a production-ready OpenAPI 3.1 specification for {{feature}}.
## Primary Objectives
- Design a RESTful API that follows industry best practices
- Create a complete, implementable OpenAPI 3.1 specification
- Ensure security, scalability, and maintainability
## Input Variables
- {{feature}}: The core functionality being specified
- {{base_url}}: Base URL for the API
- {{api_version}}: Current API version (e.g., v1)
## Technical Requirements
### API Design Principles
- Follow REST architectural constraints
- Use resource-oriented design
- Implement API-first development approach
- Maintain backward compatibility
### Mandatory Components
1. Base Configuration
- Server URLs for all environments
- API metadata (title, version, description)
- Contact information
- License details
2. Security
- OAuth2.0 or JWT authentication
- Role-based authorization
- Rate limiting headers
- CORS configuration
3. Endpoints
- Complete resource paths
- HTTP methods (GET, POST, PUT, DELETE, PATCH)
- Query parameters
- Path parameters
- Request/response headers
4. Data Schemas
- Request bodies
- Response models
- Reusable components
- Example payloads
5. Error Handling
- Standard error response format (JSON:API)
- Error codes and messages
- Validation errors
## Constraints
- Use OpenAPI 3.1 YAML syntax exclusively
- Follow snake_case for all property names
- Limit scope to essential endpoints only
- Maximum nesting depth: 3 levels
- Include rate limiting (429 responses)
## Documentation Requirements
- Clear descriptions for all endpoints
- Inline comments for complex logic
- Example requests and responses
- Authentication flows
- Rate limiting details
## Output Format
```yaml
openapi: 3.1.0
info:
title: {{feature}} API
version: {{api_version}}
# ... remaining specification
```
## Evaluation Criteria
1. Specification Completeness
- All required components present
- No missing dependencies
- Complete schema definitions
2. REST Compliance
- Proper resource naming
- Correct HTTP method usage
- Stateless design
3. Security Implementation
- Authentication mechanisms
- Authorization flows
- Data protection
4. Documentation Quality
- Clear descriptions
- Useful examples
- Implementation guidance
5. Error Handling
- Comprehensive error codes
- Clear error messages
- Proper status codes
## Additional Considerations
- Document all assumptions
- Note potential future extensions
- Include migration guidelines if applicable
- Consider versioning strategy
- Address backward compatibilityHow to use API Contract Draft (OpenAPI sketch)
Use this template as a starting point for api, architecture, software-development. Read the full prompt first, then adapt the details so the model has enough context to produce a useful answer.
- Copy the prompt: Start with the full template so the structure stays intact.
- Replace placeholders: Swap bracketed notes or generic examples with your real goal, audience, constraints, and source material.
- Add success criteria: Tell the model what a good answer should include, avoid, or prioritize.
- Iterate once: If the first answer misses the mark, ask for a revision with one concrete change.
Prompt engineering tips
- Use the tags as guardrails: Keep the output focused on api, architecture, software-development.
- Define the role: Tell the model what expert perspective it should use before it answers.
- Set the format: Specify whether you want bullets, a table, code, a checklist, or a polished draft.
Best use cases
API Contract Draft (OpenAPI sketch) is most useful for people working on api and architecture. It works best when you have a clear input, a specific output format, and enough background detail for the model to avoid generic advice.
- Turn a rough idea into a structured first draft.
- Create a repeatable workflow for api, architecture, software-development.
- Compare several options before choosing the final direction.
Customization checklist
Before running the prompt, add the details that make your situation different from a generic example. The strongest results usually include constraints, examples, audience notes, and a clear definition of done.
- Add your audience, product, role, industry, or project context.
- Include examples of what good and bad output looks like.
- Ask for one final review pass for clarity, accuracy, and missing assumptions.
Was this prompt helpful?
Sign in to leave feedback and help improve the catalogue.