Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1792
Closed
Open
Issue created Jan 02, 2019 by Administrator@rootContributor

[BUG][Java][spring][maven] FileNotFoundException when spec file is present in another jar

Created by: ashuto-sh

Description

When using openapi-generator-maven-plugin to generate sources with a yaml spec present in another jar, the models and other operation files are generated successfully but towards the end FileNotFoundException is thrown. Probably this might be due to classloader.

openapi-generator version

4.0.0-beta

Pom file configuration
...
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>4.0.0-beta</version>

        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>/openapi.yaml</inputSpec>
              <language>spring</language>
              <library>spring-mvc</library>
              <configOptions>                
                <useTags>false</useTags>
                <invokerPackage>${project.groupId}.backend.generated.server</invokerPackage>
                <apiPackage>${project.groupId}.backend.generated.server.api</apiPackage>
                <modelPackage>${project.groupId}.backend.generated.server.model</modelPackage>
              </configOptions>             
              <modelNameSuffix>Model</modelNameSuffix>
            </configuration>
          </execution>
        </executions>

        <dependencies>
          <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>${swagger.spec.artifactId}</artifactId>
            <version>${swagger.spec.version}</version>
          </dependency>
        </dependencies>
      </plugin>
...
Suggest a fix

Probable solution would be to use something similar to

this.getClass().getClassLoader().getResourceAsStream(inputSpec)

instead of

File inputSpecFile = new File(inputSpec);

at following line

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

Assignee
Assign to
Time tracking