-
Notifications
You must be signed in to change notification settings - Fork 6k
fix: remove file from fileMap in online generator #12651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances error handling and code quality in the Swagger code generator's file download functionality. The changes replace System.out.println statements with proper logging, add null safety checks, ensure proper file cleanup after downloads, and extract file operations into dedicated methods for better maintainability.
- Replaced console output with SLF4J logger for better production logging
- Added null checks to prevent NullPointerExceptions when files don't exist in the map
- Implemented proper file cleanup by removing entries from fileMap after download
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| SwaggerResource.java | Refactored downloadFile method with logging, null checks, extracted helper methods, and file cleanup logic |
| SwaggerResourceTest.java | Added comprehensive test coverage for download scenarios including happy path, file removal, missing files, and path validation |
| pom.xml | Added Mockito dependencies to support the new test mocking requirements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
Outdated
Show resolved
Hide resolved
0f83561 to
1b8334e
Compare
modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
Show resolved
Hide resolved
|
Please consider updating the documentation with a sentence about
|
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR