[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-0d6682c4-a7bf-4f12-996b-1711a9f8a789":3,"$fxh_3_w_Cs1dV6xBuyVhdf6MagkSi8f7Yhjtg5jWov1E":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"0d6682c4-a7bf-4f12-996b-1711a9f8a789","api-documentation-generator","从代码生成全面、面向开发者的API文档，包括端点、参数、示例和最佳实践","cat_coding_backend","mod_coding","sickn33,coding","---\nname: api-documentation-generator\ndescription: \"Generate comprehensive, developer-friendly API documentation from code, including endpoints, parameters, examples, and best practices\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# API Documentation Generator\n\n## Overview\n\nAutomatically generate clear, comprehensive API documentation from your codebase. This skill helps you create professional documentation that includes endpoint descriptions, request\u002Fresponse examples, authentication details, error handling, and usage guidelines.\n\nPerfect for REST APIs, GraphQL APIs, and WebSocket APIs.\n\n## When to Use This Skill\n\n- Use when you need to document a new API\n- Use when updating existing API documentation\n- Use when your API lacks clear documentation\n- Use when onboarding new developers to your API\n- Use when preparing API documentation for external users\n- Use when creating OpenAPI\u002FSwagger specifications\n\n## How It Works\n\n### Step 1: Analyze the API Structure\n\nFirst, I'll examine your API codebase to understand:\n- Available endpoints and routes\n- HTTP methods (GET, POST, PUT, DELETE, etc.)\n- Request parameters and body structure\n- Response formats and status codes\n- Authentication and authorization requirements\n- Error handling patterns\n\n### Step 2: Generate Endpoint Documentation\n\nFor each endpoint, I'll create documentation including:\n\n**Endpoint Details:**\n- HTTP method and URL path\n- Brief description of what it does\n- Authentication requirements\n- Rate limiting information (if applicable)\n\n**Request Specification:**\n- Path parameters\n- Query parameters\n- Request headers\n- Request body schema (with types and validation rules)\n\n**Response Specification:**\n- Success response (status code + body structure)\n- Error responses (all possible error codes)\n- Response headers\n\n**Code Examples:**\n- cURL command\n- JavaScript\u002FTypeScript (fetch\u002Faxios)\n- Python (requests)\n- Other languages as needed\n\n### Step 3: Add Usage Guidelines\n\nI'll include:\n- Getting started guide\n- Authentication setup\n- Common use cases\n- Best practices\n- Rate limiting details\n- Pagination patterns\n- Filtering and sorting options\n\n### Step 4: Document Error Handling\n\nClear error documentation including:\n- All possible error codes\n- Error message formats\n- Troubleshooting guide\n- Common error scenarios and solutions\n\n### Step 5: Create Interactive Examples\n\nWhere possible, I'll provide:\n- Postman collection\n- OpenAPI\u002FSwagger specification\n- Interactive code examples\n- Sample responses\n\n## Examples\n\n### Example 1: REST API Endpoint Documentation\n\n```markdown\n## Create User\n\nCreates a new user account.\n\n**Endpoint:** `POST \u002Fapi\u002Fv1\u002Fusers`\n\n**Authentication:** Required (Bearer token)\n\n**Request Body:**\n\\`\\`\\`json\n{\n  \"email\": \"user@example.com\",      \u002F\u002F Required: Valid email address\n  \"password\": \"SecurePass123!\",     \u002F\u002F Required: Min 8 chars, 1 uppercase, 1 number\n  \"name\": \"John Doe\",               \u002F\u002F Required: 2-50 characters\n  \"role\": \"user\"                    \u002F\u002F Optional: \"user\" or \"admin\" (default: \"user\")\n}\n\\`\\`\\`\n\n**Success Response (201 Created):**\n\\`\\`\\`json\n{\n  \"id\": \"usr_1234567890\",\n  \"email\": \"user@example.com\",\n  \"name\": \"John Doe\",\n  \"role\": \"user\",\n  \"createdAt\": \"2026-01-20T10:30:00Z\",\n  \"emailVerified\": false\n}\n\\`\\`\\`\n\n**Error Responses:**\n\n- `400 Bad Request` - Invalid input data\n  \\`\\`\\`json\n  {\n    \"error\": \"VALIDATION_ERROR\",\n    \"message\": \"Invalid email format\",\n    \"field\": \"email\"\n  }\n  \\`\\`\\`\n\n- `409 Conflict` - Email already exists\n  \\`\\`\\`json\n  {\n    \"error\": \"EMAIL_EXISTS\",\n    \"message\": \"An account with this email already exists\"\n  }\n  \\`\\`\\`\n\n- `401 Unauthorized` - Missing or invalid authentication token\n\n**Example Request (cURL):**\n\\`\\`\\`bash\ncurl -X POST https:\u002F\u002Fapi.example.com\u002Fapi\u002Fv1\u002Fusers \\\n  -H \"Authorization: Bearer YOUR_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"email\": \"user@example.com\",\n    \"password\": \"SecurePass123!\",\n    \"name\": \"John Doe\"\n  }'\n\\`\\`\\`\n\n**Example Request (JavaScript):**\n\\`\\`\\`javascript\nconst response = await fetch('https:\u002F\u002Fapi.example.com\u002Fapi\u002Fv1\u002Fusers', {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${token}`,\n    'Content-Type': 'application\u002Fjson'\n  },\n  body: JSON.stringify({\n    email: 'user@example.com',\n    password: 'SecurePass123!',\n    name: 'John Doe'\n  })\n});\n\nconst user = await response.json();\nconsole.log(user);\n\\`\\`\\`\n\n**Example Request (Python):**\n\\`\\`\\`python\nimport requests\n\nresponse = requests.post(\n    'https:\u002F\u002Fapi.example.com\u002Fapi\u002Fv1\u002Fusers',\n    headers={\n        'Authorization': f'Bearer {token}',\n        'Content-Type': 'application\u002Fjson'\n    },\n    json={\n        'email': 'user@example.com',\n        'password': 'SecurePass123!',\n        'name': 'John Doe'\n    }\n)\n\nuser = response.json()\nprint(user)\n\\`\\`\\`\n```\n\n### Example 2: GraphQL API Documentation\n\n```markdown\n## User Query\n\nFetch user information by ID.\n\n**Query:**\n\\`\\`\\`graphql\nquery GetUser($id: ID!) {\n  user(id: $id) {\n    id\n    email\n    name\n    role\n    createdAt\n    posts {\n      id\n      title\n      publishedAt\n    }\n  }\n}\n\\`\\`\\`\n\n**Variables:**\n\\`\\`\\`json\n{\n  \"id\": \"usr_1234567890\"\n}\n\\`\\`\\`\n\n**Response:**\n\\`\\`\\`json\n{\n  \"data\": {\n    \"user\": {\n      \"id\": \"usr_1234567890\",\n      \"email\": \"user@example.com\",\n      \"name\": \"John Doe\",\n      \"role\": \"user\",\n      \"createdAt\": \"2026-01-20T10:30:00Z\",\n      \"posts\": [\n        {\n          \"id\": \"post_123\",\n          \"title\": \"My First Post\",\n          \"publishedAt\": \"2026-01-21T14:00:00Z\"\n        }\n      ]\n    }\n  }\n}\n\\`\\`\\`\n\n**Errors:**\n\\`\\`\\`json\n{\n  \"errors\": [\n    {\n      \"message\": \"User not found\",\n      \"extensions\": {\n        \"code\": \"USER_NOT_FOUND\",\n        \"userId\": \"usr_1234567890\"\n      }\n    }\n  ]\n}\n\\`\\`\\`\n```\n\n### Example 3: Authentication Documentation\n\n```markdown\n## Authentication\n\nAll API requests require authentication using Bearer tokens.\n\n### Getting a Token\n\n**Endpoint:** `POST \u002Fapi\u002Fv1\u002Fauth\u002Flogin`\n\n**Request:**\n\\`\\`\\`json\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"your-password\"\n}\n\\`\\`\\`\n\n**Response:**\n\\`\\`\\`json\n{\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",\n  \"expiresIn\": 3600,\n  \"refreshToken\": \"refresh_token_here\"\n}\n\\`\\`\\`\n\n### Using the Token\n\nInclude the token in the Authorization header:\n\n\\`\\`\\`\nAuthorization: Bearer YOUR_TOKEN\n\\`\\`\\`\n\n### Token Expiration\n\nTokens expire after 1 hour. Use the refresh token to get a new access token:\n\n**Endpoint:** `POST \u002Fapi\u002Fv1\u002Fauth\u002Frefresh`\n\n**Request:**\n\\`\\`\\`json\n{\n  \"refreshToken\": \"refresh_token_here\"\n}\n\\`\\`\\`\n```\n\n## Best Practices\n\n### ✅ Do This\n\n- **Be Consistent** - Use the same format for all endpoints\n- **Include Examples** - Provide working code examples in multiple languages\n- **Document Errors** - List all possible error codes and their meanings\n- **Show Real Data** - Use realistic example data, not \"foo\" and \"bar\"\n- **Explain Parameters** - Describe what each parameter does and its constraints\n- **Version Your API** - Include version numbers in URLs (\u002Fapi\u002Fv1\u002F)\n- **Add Timestamps** - Show when documentation was last updated\n- **Link Related Endpoints** - Help users discover related functionality\n- **Include Rate Limits** - Document any rate limiting policies\n- **Provide Postman Collection** - Make it easy to test your API\n\n### ❌ Don't Do This\n\n- **Don't Skip Error Cases** - Users need to know what can go wrong\n- **Don't Use Vague Descriptions** - \"Gets data\" is not helpful\n- **Don't Forget Authentication** - Always document auth requirements\n- **Don't Ignore Edge Cases** - Document pagination, filtering, sorting\n- **Don't Leave Examples Broken** - Test all code examples\n- **Don't Use Outdated Info** - Keep documentation in sync with code\n- **Don't Overcomplicate** - Keep it simple and scannable\n- **Don't Forget Response Headers** - Document important headers\n\n## Documentation Structure\n\n### Recommended Sections\n\n1. **Introduction**\n   - What the API does\n   - Base URL\n   - API version\n   - Support contact\n\n2. **Authentication**\n   - How to authenticate\n   - Token management\n   - Security best practices\n\n3. **Quick Start**\n   - Simple example to get started\n   - Common use case walkthrough\n\n4. **Endpoints**\n   - Organized by resource\n   - Full details for each endpoint\n\n5. **Data Models**\n   - Schema definitions\n   - Field descriptions\n   - Validation rules\n\n6. **Error Handling**\n   - Error code reference\n   - Error response format\n   - Troubleshooting guide\n\n7. **Rate Limiting**\n   - Limits and quotas\n   - Headers to check\n   - Handling rate limit errors\n\n8. **Changelog**\n   - API version history\n   - Breaking changes\n   - Deprecation notices\n\n9. **SDKs and Tools**\n   - Official client libraries\n   - Postman collection\n   - OpenAPI specification\n\n## Common Pitfalls\n\n### Problem: Documentation Gets Out of Sync\n**Symptoms:** Examples don't work, parameters are wrong, endpoints return different data\n**Solution:** \n- Generate docs from code comments\u002Fannotations\n- Use tools like Swagger\u002FOpenAPI\n- Add API tests that validate documentation\n- Review docs with every API change\n\n### Problem: Missing Error Documentation\n**Symptoms:** Users don't know how to handle errors, support tickets increase\n**Solution:**\n- Document every possible error code\n- Provide clear error messages\n- Include troubleshooting steps\n- Show example error responses\n\n### Problem: Examples Don't Work\n**Symptoms:** Users can't get started, frustration increases\n**Solution:**\n- Test every code example\n- Use real, working endpoints\n- Include complete examples (not fragments)\n- Provide a sandbox environment\n\n### Problem: Unclear Parameter Requirements\n**Symptoms:** Users send invalid requests, validation errors\n**Solution:**\n- Mark required vs optional clearly\n- Document data types and formats\n- Show validation rules\n- Provide example values\n\n## Tools and Formats\n\n### OpenAPI\u002FSwagger\nGenerate interactive documentation:\n```yaml\nopenapi: 3.0.0\ninfo:\n  title: My API\n  version: 1.0.0\npaths:\n  \u002Fusers:\n    post:\n      summary: Create a new user\n      requestBody:\n        required: true\n        content:\n          application\u002Fjson:\n            schema:\n              $ref: '#\u002Fcomponents\u002Fschemas\u002FCreateUserRequest'\n```\n\n### Postman Collection\nExport collection for easy testing:\n```json\n{\n  \"info\": {\n    \"name\": \"My API\",\n    \"schema\": \"https:\u002F\u002Fschema.getpostman.com\u002Fjson\u002Fcollection\u002Fv2.1.0\u002Fcollection.json\"\n  },\n  \"item\": [\n    {\n      \"name\": \"Create User\",\n      \"request\": {\n        \"method\": \"POST\",\n        \"url\": \"{{baseUrl}}\u002Fapi\u002Fv1\u002Fusers\"\n      }\n    }\n  ]\n}\n```\n\n## Related Skills\n\n- `@doc-coauthoring` - For collaborative documentation writing\n- `@copywriting` - For clear, user-friendly descriptions\n- `@test-driven-development` - For ensuring API behavior matches docs\n- `@systematic-debugging` - For troubleshooting API issues\n\n## Additional Resources\n\n- [OpenAPI Specification](https:\u002F\u002Fswagger.io\u002Fspecification\u002F)\n- [REST API Best Practices](https:\u002F\u002Frestfulapi.net\u002F)\n- [GraphQL Documentation](https:\u002F\u002Fgraphql.org\u002Flearn\u002F)\n- [API Design Patterns](https:\u002F\u002Fwww.apiguide.com\u002F)\n- [Postman Documentation](https:\u002F\u002Flearning.postman.com\u002Fdocs\u002F)\n\n---\n\n**Pro Tip:** Keep your API documentation as close to your code as possible. Use tools that generate docs from code comments to ensure they stay in sync!\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,162,381,"2026-05-16 13:03:20",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"c758ef08-8542-4ed2-b3d5-a504eeed9350","1.0.0","api-documentation-generator.zip",4535,"uploads\u002Fskills\u002F0d6682c4-a7bf-4f12-996b-1711a9f8a789\u002Fapi-documentation-generator.zip","94f7554c936363507ca3c73caf4651b05d54902b79649316d4b2a52816a09a0d","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":11561}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]