Open chrylis opened 4 years ago
To prevent the contents of the package invalidPackageName
from being generated, add the option <generateSupportingFiles>false</generateSupportingFiles>
.
Using the options
<generateApis>false</generateApis>
<generateSupportingFiles>false</generateSupportingFiles>
will do what you intend, if I understood you correctly, i.e. will just generate the models.
Maybe this is just an issue of naming things
?
You can workaround this by using properties in your pom.xml :
<properties>
<openapi.generator.maven.plugin.generateApis>false</openapi.generator.maven.plugin.generateApis>
</properties>
org.openapitools.codegen.DefaultGenerator:208
generateApis = GlobalSettings.getProperty(CodegenConstants.APIS) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.APIS, null);
This condition result always returns Boolean.TRUE
Please, look at my solution in PR https://github.com/OpenAPITools/openapi-generator/pull/14126
closed via #14126
Regression reported in https://github.com/OpenAPITools/openapi-generator/issues/14119. Will revert the fix.
It would be useful for the Maven plugin to log the exact config it is passing to DefaultGenerator at DEBUG; even using mvn -X does not provide output useful to debugging this problem.
The latest snapshot version of OpenAPI Generator prints most of the config. It currently looks like this:
[DEBUG] GeneratorSettings#build: GeneratorSettings{generatorName='java', apiPackage='null', modelPackage='null', invokerPackage='null', packageName='null', apiNameSuffix='null', modelNamePrefix='null', modelNameSuffix='null', groupId='null', artifactId='null', artifactVersion='null', library='native', instantiationTypes={}, typeMappings={}, additionalProperties={gitHost=dummyGitHost, releaseNote=Minor update, gitUserId=GIT_USER_ID, gitRepoId=GIT_REPO_ID}, importMappings={}, languageSpecificPrimitives=[], reservedWordsMappings={dummyKey=dummyValue}, gitHost='dummyGitHost', gitUserId='GIT_USER_ID', gitRepoId='GIT_REPO_ID', releaseNote='Minor update', httpUserAgent='null'}
[DEBUG] WorkflowSettings#build: WorkflowSettings{inputSpec='C:\Users\margebe\Desktop\openapi-generator-input.json', outputDir='C:\Users\margebe\Desktop\Issue15203\target\generated-sources\openapi', verbose=false, skipOverwrite=false, removeOperationIdPrefix=false, logToStderr=false, validateSpec=true, enablePostProcessFile=false, enableMinimalUpdate=false, strictSpecBehavior=true, templateDir='null', templatingEngineName='mustache', ignoreFileOverride='null', globalProperties={apis=dummyType1,dummyType2}, generateAliasAsModel=false}
To add the (as far as I can see) last piece of information to the debug logs, I created https://github.com/OpenAPITools/openapi-generator/pull/16961. This PR will add logging of "GlobalSettings", i.e. mostly environment variables.
Note: This bug is encountered when using the Maven plugin, but it may be that it's a bug in the generator itself; I'm not sure whether the plugin is invoking it correctly.
Description
The Maven plugin version 4.2.1 ignores the documented
generateApis
andgenerateModels
configuration parameters.I am trying to separate the data types and the generated REST client into Maven modules, using these parameters to generate the code in the appropriate place. However, the Maven plugin appears not to inspect them at all.
This is not related to any specific spec file but is a matter of the generator invocation itself.
openapi-generator version
org.openapitools:openapi-generator-maven-plugin:4.2.1:generate
Steps to reproduce
I used the following POM plugin declaration:
When running using
mvn -X
, the mojo configuration model reflects the documented parameters:The configurator applies the
generateApis
setting:Nevertheless, the generator generates a REST client (using an incorrectly "derived" package name):
and the build fails because of missing dependencies.
The inverse does not seem to be true; i.e., the
generateModels=false
setting is respected.Suggest a fix
It would be useful for the Maven plugin to log the exact config it is passing to
DefaultGenerator
at DEBUG; even usingmvn -X
does not provide output useful to debugging this problem.