Skip to content

[BUG] Maven-plugin - Build fails if inputSpecs are a file from a remote URL #3841

@RockyMM

Description

@RockyMM
Description

If an URL is used as the inputSpecs, the build fails at the very end (all files are generated) with:

INFO] writing file D:\Projects\mdh-gen\mdh-modelgen-test\target\generated-sources\mdh\.openapi-generator-ignore
[INFO] writing file D:\Projects\mdh-gen\mdh-modelgen-test\target\generated-sources\mdh\.openapi-generator\VERSION
[ERROR] D:\Projects\mdh-gen\mdh-modelgen-test\https:\test.com\swagger\spec\mdh.yml [0:0]: unexpected error in Open-API generation
D:\Projects\mdh-gen\mdh-modelgen-test\https:\test.com\swagger\spec\mdh.yml [0:0]: unexpected error in Open-API generation


java.lang.RuntimeException: Could not find https:/test.com/swagger/spec/mdh.yml on the classpath
    at io.swagger.v3.parser.util.ClasspathHelper.loadFileFromClasspath (ClasspathHelper.java:31)
    at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:706)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
openapi-generator version

Maven plugin version

            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>4.1.1</version>
OpenAPI declaration file content or url

https://github.com/RockyMM/openapi-modelgen-test/blob/master/src/main/openapi/mdh.yml

Command line used for generation
mvn clean generate-sources
Steps to reproduce

In the test project above set inputSpec to be an URL of a remote file.
Run mvn clean generate-sources on the test project.

Suggest a fix

In the class:

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java

Seems that inputSpecFile.exists() is not doing it's job properly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions