openapi-to-application-code
它能做什么
这个工具可以根据一个描述 API 的文件(称为 OpenAPI)创建一个完整的、可直接使用的应用程序。它会理解 API 应该如何工作,并生成所需的代码。
适用场景
- ✓当你已经有 API 描述文件,并希望得到一个使用该 API 的应用程序时。
- ✓当你想基于现有 API 快速创建一个应用原型时。
- ✓当你开始一个新项目,希望自动生成基础代码结构时。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/openapi-to-application-code/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“根据 https://api.example.com/v2/openapi.json 中的 OpenAPI 规范生成一个应用,使用 Spring Boot 框架,并采用 JWT 身份验证。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会读取 API 描述(OpenAPI),理解其中的数据和可用功能。然后它会搭建应用的结构,为各个部分编写代码(比如接收请求、处理数据、返回响应),并添加测试和文档。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Generate Application from OpenAPI Spec
Your goal is to generate a complete, working application from an OpenAPI specification using the active framework's conventions and best practices.
Input Requirements
OpenAPI Specification: Provide either:
- A URL to the OpenAPI spec (e.g.,
https://api.example.com/openapi.json) - A local file path to the OpenAPI spec
- The full OpenAPI specification content pasted directly
- A URL to the OpenAPI spec (e.g.,
Project Details (if not in spec):
- Project name and description
- Target framework and version
- Package/namespace naming conventions
- Authentication method (if not specified in OpenAPI)
Generation Process
Step 1: Analyze the OpenAPI Specification
- Validate the OpenAPI spec for completeness and correctness
- Identify all endpoints, HTTP methods, request/response schemas
- Extract authentication requirements and security schemes
- Note data model relationships and constraints
- Flag any ambiguities or incomplete definitions
Step 2: Design Application Architecture
- Plan directory structure appropriate for the framework
- Identify controller/handler grouping by resource or domain
- Design service layer organization for business logic
- Plan data models and entity relationships
- Design configuration and initialization strategy
Step 3: Generate Application Code
- Create project structure with build/package configuration files
- Generate models/DTOs from OpenAPI schemas
- Generate controllers/handlers with route mappings
- Generate service layer with business logic
- Generate repository/data access layer if applicable
- Add error handling, validation, and logging
- Generate configuration and startup code
Step 4: Add Supporting Files
- Generate appropriate unit tests for services and controllers
- Create README with setup and running instructions
- Add .gitignore and environment configuration templates
- Generate API documentation files
- Create example requests/integration tests
Output Structure
The generated application will include:
project-name/
├── README.md # Setup and usage instructions
├── [build-config] # Framework-specific build files (pom.xml, build.gradle, package.json, etc.)
├── src/
│ ├── main/
│ │ ├── [language]/
│ │ │ ├── controllers/ # HTTP endpoint handlers
│ │ │ ├── services/ # Business logic
│ │ │ ├── models/ # Data models and DTOs
│ │ │ ├── repositories/ # Data access (if applicable)
│ │ │ └── config/ # Application configuration
│ │ └── resources/ # Configuration files
│ └── test/
│ ├── [language]/
│ │ ├── controllers/ # Controller tests
│ │ └── services/ # Service tests
│ └── resources/ # Test configuration
├── .gitignore
├── .env.example # Environment variables template
└── docker-compose.yml # Optional: Docker setup (if applicable)
Best Practices Applied
- Framework Conventions: Follows framework-specific naming, structure, and patterns
- Separation of Concerns: Clear layers with controllers, services, and repositories
- Error Handling: Comprehensive error handling with meaningful responses
- Validation: Input validation and schema validation throughout
- Logging: Structured logging for debugging and monitoring
- Testing: Unit tests for services and controllers
- Documentation: Inline code documentation and setup instructions
- Security: Implements authentication/authorization from OpenAPI spec
- Scalability: Design patterns support growth and maintenance
Next Steps
After generation:
- Review the generated code structure and make customizations as needed
- Install dependencies according to framework requirements
- Configure environment variables and database connections
- Run tests to verify generated code
- Start the development server
- Test endpoints using the provided examples
Questions to Ask if Needed
- Should the application include database/ORM setup, or just in-memory/mock data?
- Do you want Docker configuration for containerization?
- Should authentication be JWT, OAuth2, API keys, or basic auth?
- Do you need integration tests or just unit tests?
- Any specific database technology preferences?
- Should the API include pagination, filtering, and sorting examples?
常见问题
什么是 OpenAPI 规范?
它是一个描述 API 工作方式的文件,详细说明 API 接收和返回哪些数据,以及可以执行哪些操作。
生成的应用能直接运行吗?
可以。目标是生成一个完整且可用的应用,只需稍作配置就能运行。
我能选择应用使用的技术吗?
可以。如果 API 规范中没有指定,你可以自己指定想用的框架和其他技术。
详情
作者的原始描述
Generate a complete, production-ready application from an OpenAPI specification
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7313
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。