http-generate
npx skills add https://github.com/spring-ai-alibaba/examples --skill http-generate
Agent 安装分布
Skill 文档
HTTP Generator
This skill automatically analyzes Spring Boot Web controllers and generates HTTP request examples for all REST endpoints, saving them as .http files in their respective module directories according to the task specification.
When to Use
Use this skill when you need to:
- Generate API documentation for testing
- Create HTTP request examples for new modules
- Document existing Spring Boot REST controllers
- Provide ready-to-use request samples for developers
- Automate API testing setup
- Create interface specifications for team collaboration
How to Use
Generate HTTP Requests for a Single Module
Execute the HTTP generator script to create request examples for all controllers in a module:
python .claude/skills/http-generate/scripts/http_generator.py <module_path> [output_file]
Generate HTTP Requests for All Modules
Use the all parameter to automatically discover and generate HTTP files for all modules with controllers:
python .claude/skills/http-generate/scripts/http_generator.py all
Parameters:
module_path(required): Path to the Spring Boot module directory, orallto process all modulesoutput_file(optional): Custom output file path (default:{module_name}.http)
Examples:
# Generate for chat module-generate.md (creates basic/chat/chat.http)
python .claude/skills/http-generate/scripts/http_generator.py basic/chat
# Generate for all modules automatically
python .claude/skills/http-generate/scripts/http_generator.py all
# Generate for graph module-generate.md (creates graph/graph.http)
python .claude/skills/http-generate/scripts/http_generator.py graph/parallel
# Generate with custom output file
python .claude/skills/http-generate/scripts/http_generator.py basic/chat custom-api.http
# Generate for different modules
python .claude/skills/http-generate/scripts/http_generator.py basic/tool
python .claude/skills/http-generate/scripts/http_generator.py basic/image
python .claude/skills/http-generate/scripts/http_generator.py graph/stream
Supported Controller Patterns
The skill automatically detects and generates requests for:
HTTP Methods
- GET
@GetMapping– Query operations - POST
@PostMapping– Create operations - PUT
@PutMapping– Update operations - DELETE
@DeleteMapping– Delete operations
Parameter Types
@RequestParamwith default values@RequestParamwithout default values@PathVariablefor path parameters- URL encoding for Chinese characters and special values
Controller Annotations
@RestController– JSON API endpoints@Controller– MVC controllers@RequestMapping– Base path mapping
Output Format (Task Specification)
The skill generates .http files according to the task specification format:
Basic Format
# {Controllerç±»å}ç{æ¹æ³å}æ¹æ³
{HTTP_METHOD} {宿´URLè·¯å¾}?{åæ°é®å¼å¯¹}
###
# {Controllerç±»å}ç{æ¹æ³å}æ¹æ³
{HTTP_METHOD} {宿´URLè·¯å¾}?{åæ°é®å¼å¯¹}
Generated Example
# ChatControllerç±»çcallChatæ¹æ³
GET http://localhost:8080/basic/chat/call?query=ä½ å¥½ï¼å¾é«å
´è®¤è¯ä½ ï¼è½ç®åä»ç»ä¸ä¸èªå·±åï¼
###
# ChatControllerç±»çstreamChatæ¹æ³
GET http://localhost:8080/basic/chat/stream?query=ä½ å¥½ï¼å¾é«å
´è®¤è¯ä½ ï¼è½ç®åä»ç»ä¸ä¸èªå·±åï¼
###
# ChatControllerç±»çcallOptionæ¹æ³
GET http://localhost:8080/basic/chat/call/option?query=ä½ å¥½ï¼å¾é«å
´è®¤è¯ä½ ï¼è½ç®åä»ç»ä¸ä¸èªå·±åï¼
Generated Request Features
Each generated HTTP request includes:
- Method Documentation: Comment format
# Controllerç±»åçæ¹æ³åæ¹æ³ - Complete URL: Full endpoint URL with base path
- Default Parameters: All @RequestParam values with defaults
- Proper Encoding: URL encoding for Chinese characters
- Query String: Properly formatted parameter strings with
?and& - Separators:
###used to separate different interfaces - File Organization: Grouped by controller and module
Module Discovery
The skill automatically:
- Discovers Modules: Scans project directories for modules containing controllers
- Identifies Controllers: Files ending with
Controller.java - Analyzes Annotations: Extracts mapping annotations
- Extracts Parameters: Finds @RequestParam configurations
- Builds URLs: Constructs complete request URLs
- Generates Examples: Creates ready-to-use HTTP requests
Supported Spring Boot Patterns
Example 1: Simple GET Controller
@RestController
@RequestMapping("/basic/chat")
public class ChatController {
@GetMapping("/call")
public String callChat(
@RequestParam(value = "query",
defaultValue = "ä½ å¥½ï¼å¾é«å
´è®¤è¯ä½ ï¼è½ç®åä»ç»ä¸ä¸èªå·±åï¼",
required = false) String query) {
return chatClient.prompt(query).call().content();
}
}
Generated Request:
# ChatControllerç±»çcallChatæ¹æ³
GET http://localhost:8080/basic/chat/call?query=ä½ å¥½ï¼å¾é«å
´è®¤è¯ä½ ï¼è½ç®åä»ç»ä¸ä¸èªå·±åï¼
Example 2: Complex Parameters
@GetMapping("/expand-translate")
public Map<String, Object> expandAndTranslate(
@RequestParam(value = "query", defaultValue = "ä½ å¥½", required = false) String query,
@RequestParam(value = "expander_number", defaultValue = "3", required = false) Integer expanderNumber,
@RequestParam(value = "translate_language", defaultValue = "english", required = false) String translateLanguage) {
// implementation
}
Generated Request:
# ParallelControllerç±»çexpandAndTranslateæ¹æ³
GET http://localhost:8080/graph/parallel/expand-translate?query=ä½ å¥½&expander_number=3&translate_language=english
Example 3: Multiple Controllers
For modules with multiple controllers, the skill generates requests for all with ### separators:
# TimeControllerç±»çcallæ¹æ³
GET http://localhost:8080/basic/tool/time/call?query=请åè¯æç°å¨å京æ¶é´å ç¹äº
###
# TimeControllerç±»çcallToolFunctionæ¹æ³
GET http://localhost:8080/basic/tool/time/call/function?query=请åè¯æç°å¨å京æ¶é´å ç¹äº
###
# SearchControllerç±»çsearchæ¹æ³
GET http://localhost:8080/basic/tool/search?query=Spring+AI
File Organization (Task Specification)
Output Location
- Default:
{module_name}/{module_name}.http - File Naming: Uses module name as filename (e.g.,
chat.http,tool.http) - Custom: User-specified path
- Encoding: UTF-8 for Chinese characters
Directory Structure Example
basic/
âââ chat/
â âââ chat.http â Generated file
â âââ src/main/java/.../ChatController.java
âââ tool/
â âââ tool.http â Generated file
â âââ src/main/java/.../TimeController.java
âââ image/
âââ image.http â Generated file
âââ src/main/java/.../ImageController.java
Task Specification Compliance
The generated files strictly follow the task specification:
- æä»¶å½å: 以模ååç§°å½åï¼ä½¿ç¨
.httpåç¼ â - æä»¶ä½ç½®: æ¾ç½®å¨å¯¹åºæ¨¡åçæ ¹ç®å½ä¸ â
- å å®¹æ¥æº: åºäº Controller ç±»ä¸çæ¥å£æ¹æ³çæ â
- æ³¨éæ ¼å¼: 使ç¨
# Controllerç±»åçæ¹æ³åæ¹æ³â - åé符: 使ç¨
###åéä¸åæ¥å£ â - åæ°å¤ç: æ£ç¡®å¤çæ¥è¯¢åæ°æ¼æ¥ â
Integration with Development Workflow
Use with IDE HTTP Client
The generated .http files work seamlessly with:
- IntelliJ IDEA HTTP Client
- VS Code REST Client
- Postman Import
- curl commands
Automated Documentation
Perfect for:
- API documentation generation
- Testing automation
- Developer onboarding
- Contract testing
- Integration testing setup
Customization Options
Modify Script Behavior
Edit scripts/http_generator.py to customize:
- Base URL: Change from
http://localhost:8080 - Output Format: Modify request template according to specification
- Parameter Handling: Add support for other annotations
- File Patterns: Change controller detection logic
- Encoding: Adjust URL encoding rules
Extend Functionality
Add support for:
- POST body parameters
- Header handling
- Authentication headers
- Multi-parameter requests
- File upload examples
Notes
- The script automatically discovers all modules with controllers when using
allparameter - Only processes files ending with
Controller.java - Supports UTF-8 encoding for Chinese parameters
- Requires Python 3 and no external dependencies
- Handles complex Spring Boot annotation patterns
- Preserves parameter defaults from source code
- Groups requests by controller for clarity
- Follows task specification format exactly
Error Handling
Common issues and solutions:
- No controllers found: Ensure module contains
*Controller.javafiles - Missing @RequestMapping: Controllers without base mapping will use root path
- Complex parameters: Some advanced parameter types may need manual adjustment
- Encoding issues: Chinese characters are automatically URL-encoded
- Module discovery: Use
allparameter to auto-discover modules with controllers