guanzhenxing opened a new pull request, #6050:
URL: https://github.com/apache/shenyu/pull/6050
# Add Swagger Import Functionality to ShenYu Admin
## Description
This PR adds a comprehensive Swagger document import functionality to ShenYu
Admin, allowing users to import API documentation from external Swagger/OpenAPI
endpoints directly into the ShenYu admin system.
## Features
### 🚀 New Features
- **Swagger Document Import**: Import API documentation from external
Swagger/OpenAPI endpoints
- **Multi-Version Support**: Full support for both Swagger 2.0 and OpenAPI
3.0 formats
- **Connection Testing**: Test connectivity to Swagger endpoints before
importing
- **URL Validation**: Comprehensive validation for Swagger URLs with proper
error handling
- **Document Parsing**: Enhanced SwaggerDocParser with version-aware parsing
capabilities
### 🔧 Technical Implementation
#### New Components Added:
1. **SwaggerImportController** - REST API endpoints for import operations
2. **SwaggerImportService** - Service interface for import logic
3. **SwaggerImportServiceImpl** - Implementation with HTTP client integration
4. **SwaggerImportRequest** - Request DTO with validation annotations
5. **SwaggerVersion** - Enumeration for version handling
6. **Enhanced SwaggerDocParser** - Updated to support both Swagger 2.0 and
OpenAPI 3.0
#### API Endpoints:
- `POST /swagger/import` - Import Swagger documentation
- `POST /swagger/test-connection` - Test connection to Swagger URL
## Code Changes
### Files Added:
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SwaggerImportController.java`
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/SwaggerImportRequest.java`
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SwaggerImportService.java`
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImpl.java`
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerVersion.java`
-
`shenyu-admin/src/test/java/org/apache/shenyu/admin/service/SwaggerImportServiceTest.java`
### Files Modified:
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java`
- Added version detection logic
- Enhanced to support both Swagger 2.0 and OpenAPI 3.0 formats
- Refactored methods to accept version parameters
- Improved schema definition handling for different versions
## Version Support Details
### Swagger 2.0 Support:
- Schema definitions: `definitions` object
-
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]