Home / Market / doc api

doc api

doc-api

claude-command★ 346940 dlgithubMITInstall in CosmosUpstream Source

Documentation & Preview

--- allowed-tools: Read, Write, Edit, Bash argument-hint: [api-type] | --openapi | --graphql | --rest | --grpc | --interactive description: Generate comprehensive API documentation from code with interactive examples and testing capabilities

---

API Documentation Generator

Generate API documentation from code: $ARGUMENTS

Current API Context

Task

Generate comprehensive API documentation with interactive features: $ARGUMENTS

  1. Code Analysis and Discovery
  1. Documentation Tool Selection
  1. API Specification Generation

For REST APIs with OpenAPI:

   openapi: 3.0.0
   info:
     title: $ARGUMENTS API
     version: 1.0.0
     description: Comprehensive API for $ARGUMENTS
   servers:
     - url: https://api.example.com/v1
   paths:
     /users:
       get:
         summary: List users
         parameters:
           - name: page
             in: query
             schema:
               type: integer
         responses:
           '200':
             description: Successful response
             content:
               application/json:
                 schema:
                   type: array
                   items:
                     $ref: '#/components/schemas/User'
   components:
     schemas:
       User:
         type: object
         properties:
           id:
             type: integer
           name:
             type: string
           email:
             type: string
  1. Endpoint Documentation
  1. Request/Response Examples
  1. Authentication Documentation
  1. Data Model Documentation
  1. Error Handling Documentation
  1. Interactive Documentation Setup

Swagger UI Integration:

   <!DOCTYPE html>
   <html>
   <head>
     <title>API Documentation</title>
     <link rel="stylesheet" type="text/css" href="./swagger-ui-bundle.css" />
   </head>
   <body>
     <div id="swagger-ui"></div>
     <script src="./swagger-ui-bundle.js"></script>
     <script>
       SwaggerUIBundle({
         url: './api-spec.yaml',
         dom_id: '#swagger-ui'
       });
     </script>
   </body>
   </html>
  1. Code Annotation and Comments
  1. Automated Documentation Generation

For Node.js/Express:

    const swaggerJsdoc = require('swagger-jsdoc');
    const swaggerUi = require('swagger-ui-express');
    
    const options = {
      definition: {
        openapi: '3.0.0',
        info: {
          title: 'API Documentation',
          version: '1.0.0',
        },
      },
      apis: ['./routes/*.js'],
    };
    
    const specs = swaggerJsdoc(options);
    app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
  1. Testing Integration
  1. Version Management
  1. Performance Documentation
  1. SDK and Client Library Documentation
  1. Environment-Specific Documentation
  1. Security Documentation
  1. Maintenance and Updates

Framework-Specific Examples:

FastAPI (Python):

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI(title="My API", version="1.0.0")

class User(BaseModel):
    id: int
    name: str
    email: str

@app.get("/users/{user_id}", response_model=User)
async def get_user(user_id: int):
    """Get a user by ID."""
    return {"id": user_id, "name": "John", "email": "john@example.com"}

Spring Boot (Java):

@RestController
@Api(tags = "Users")
public class UserController {
    
    @GetMapping("/users/{id}")
    @ApiOperation(value = "Get user by ID")
    public ResponseEntity<User> getUser(
        @PathVariable @ApiParam("User ID") Long id) {
        // Implementation
    }
}

Remember to keep documentation up-to-date with code changes and make it easily accessible to both internal teams and external consumers.