swagger-api / swagger-api/swagger-codegen

io.swagger : swagger-codegen-maven-plugin : 2.1.6 / 2.2.1

Open
#3,583 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Swagger Codegen Maven Plugin
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

In a multi-module maven project when running a 'reactor build', relative paths configured in a subproject, do not resolve relatively to the sub-projects,'

Swagger-codegen version

Found in Versions: 2.1.6 and 2.2.1

Swagger declaration file content or url
Maven plugin configuration used
<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <!-- <version>2.1.6</version> -->
    <version>2.2.1</version>
    <executions><execution>
        <goals><goal>generate</goal></goals>
        <phase>generate-sources</phase>
        <configuration>
            <inputSpec>src/main/resources/api.yaml</inputSpec>
            <language>java</language>
            <configOptions><dateLibrary>joda</dateLibrary></configOptions>
            <library>jersey2</library>
        </configuration>
    </execution></executions>
</plugin>
Steps to reproduce

pom.xml
codegen-module/pom.xml
codegen-module/src/main/resources/api.yml

if I build codegen-module standalone, it works
if I build the multi-module project, it fails saying

'src/main/resources/api.yml not found

Related issues

not found

Suggest a Fix

The maven plugin 'CodeGenMojo' should check whether the path given in inputSpec is relative or absolute.
It should prefix relative paths it with the value of maven variable ${project.basedir}.

Workaround
<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <!-- <version>2.1.6</version> -->
    <version>2.2.1</version>
    <executions><execution>
        <goals><goal>generate</goal></goals>
        <phase>generate-sources</phase>
        <configuration>
            <inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
            <language>java</language>
            <configOptions><dateLibrary>joda</dateLibrary></configOptions>
            <library>jersey2</library>
        </configuration>
    </execution></executions>
</plugin>

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

Start with the CodeGenMojo entry point and the pom.xml files named in the report. Reproduce the difference between standalone and reactor builds using codegen-module/src/main/resources/api.yml, then inspect how the relative inputSpec is resolved. Done means the relative path works in both build modes without requiring ${project.basedir}.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
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.