You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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,'
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}.
I have to confess that all our projects already use ${project.basedir}/... as the input spec path, thus I didn't note this (or didn't think it was important, not sure).
A bit of analysis of this issue:
The maven plugin simply passes the value to the CodegenConfigurator
CodegenConfigurator then calls SwaggerParser.read() with this value, ...
... which passes this to Swagger20Parser.read, which tries to resolve this as a HTTP url (if it starts with http) or a file path (which will be relative to the current working directory), with fallback to the class path.
When running maven, the current working directory is the directory from which maven is called (which can be different from the location of the pom.xml, even if we don't have a submodule situation).
I guess prefixing with ${project.basedir} could work, though one needs to take care that http URIs are not broken when relative file paths are prefixed. (Also, windows paths like c:\....)
Also, it looks like the same issue appears when using the configurationFile ... both for finding the configuration file from the maven plugin, and when the configurationFile contains a relative input spec file name.
The latter is likely also a problem when using the CLI version. (I.e. you start call the CLI with a configuration file which is not in the current directory, and the config file contains a relative file name. This will be resolved relative to the calling directory, not the config file directory.)
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
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
The text was updated successfully, but these errors were encountered: