OpenAPITools / OpenAPITools/openapi-generator
[BUG] Error creating hash file when trying to retrieve an OpenAPI specification file from a private GitLab repository
Nobody has claimed this yet.
- 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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Error creating hash file when trying to retrieve an OpenAPI specification file from a private GitLab repository
openapi-generator version
7.10.0
OpenAPI declaration file content or url
any file
Generation Details
Java, maven
Steps to reproduce
According to the GitLab API, to retrieve a file from the repository, the following URL format should be used:
https://gitlab.company.com/api/v4/projects/2233/repository/files/openapi.yml/raw?ref=develop&private_token=glpat-xxxYYYyyyZZZ
However, it is recommended to send the PRIVATE_TOKEN as a header.
When generating the API and DTO, the following error occurs:
java.io.FileNotFoundException: [PATH]\target\generated-sources\.openapi-generator\raw?ref=develop&private_token=glpat-xxxYYYyyyZZZ-default.sha256 (Syntax error in file name, folder name, or volume label) at java.io.FileOutputStream.open0 (Native Method) at java.io.FileOutputStream.open (FileOutputStream.java:289) at java.io.FileOutputStream.<init> (FileOutputStream.java:230) at com.google.common.io.Files$FileByteSink.openStream (Files.java:197) at com.google.common.io.Files$FileByteSink.openStream (Files.java:185) at com.google.common.io.ByteSink$AsCharSink.openStream (ByteSink.java:152) at com.google.common.io.CharSink.write (CharSink.java:99) at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:979) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:299) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:963) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:296) at org.apache.maven.cli.MavenCli.main (MavenCli.java:199) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103) at java.lang.reflect.Method.invoke (Method.java:580) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Despite this error, the API and DTO are generated successfully.
Related issues/PRs
Suggest a fix
The issue is likely due to the fact that when using a similar URL, the last section of the URL is used as the name for the hash file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in CodeGenMojo.java around the reported failure at line 979, focusing on how the retrieved URL is used to name the hash file. Reproduce the Maven generation with the private GitLab URL and check the generated file path. Done means hash-file creation no longer fails on URL query text while API and DTO generation still succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100