Skip to content

Conversation

@daniel-kmiecik
Copy link
Contributor

@daniel-kmiecik daniel-kmiecik commented Nov 17, 2025

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if 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\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

  • System.out.println statements were replaced with a logger
  • logic for reading file bytes and deleting the file was extracted into separate methods
  • a null check for g and its filename was added to return a 404 response instead of throwing an exception when the file does not exist in the map
  • remove downloaded file from fileMap after download

Copy link

Copilot AI left a 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.

@daniel-kmiecik daniel-kmiecik changed the title fix: remove file from online generator fix: remove file from fileMap in online generator Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants