OpenAPITools / OpenAPITools/openapi-generator

[BUG] Description OpenApi Generator 5.0.0 beta gradle-wraper.jar corrupted when copying to a Java Api Client

Open
#7,137 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

corrupts the gradle-wrapper.jar when creating a Java API Client

openapi-generator version

OpenApi Generator 5.0.0 beta

OpenAPI declaration file content or url
Generation Details
Steps to reproduce

I am using these tools at my company Guidewire Software to generate REST Client APIs and when I upgraded from Generator 4.3.1 to 5.0.0 beta the gradle-wrapper.jar it creates is corrupted.
The cause is that jar when copied it is being converted into a string array instead of byte[].

The problem starts in DefaultGenerator
private void generateSupportingFiles(List files, Map<String, Object> bundle) {

if you go to this call
File written = processTemplateToFile(bundle, support.templateFile, outputFilename, shouldGenerate, CodegenConstants.SUPPORTING_FILES);
Then
if (shouldGenerate) {
return this.templateProcessor.write(templateData, templateName, target);
then
TemplateManager
public File write(Map<String, Object> data, String template, File target) throws IOException {
This gets the jar file as a string, it should be bytes
String templateContent = this.engineAdapter.compileTemplate(this, data, template);

Related issues/PRs
Suggest a fix

I have fixed the code in my copy but only as a hack for the one jar. It needs to be managed for all jars like it was in 4.3.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce Java API client generation with OpenAPI Generator 5.0.0 beta and compare the gradle-wrapper.jar output with version 4.3.1. Start in DefaultGenerator.generateSupportingFiles and follow processTemplateToFile into TemplateManager.write and the engineAdapter.compileTemplate call; done means generated JAR files remain valid binary content rather than being treated as strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.