fix: remove file from fileMap in online generator#12651
Merged
daniel-kmiecik merged 3 commits intomasterfrom Nov 18, 2025
Merged
fix: remove file from fileMap in online generator#12651daniel-kmiecik merged 3 commits intomasterfrom
daniel-kmiecik merged 3 commits intomasterfrom
Conversation
There was a problem hiding this comment.
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
3 tasks
modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
Show resolved
Hide resolved
Contributor
|
Please consider updating the documentation with a sentence about
|
ewaostrowska
previously approved these changes
Nov 18, 2025
ewaostrowska
approved these changes
Nov 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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