swagger-api / swagger-api/swagger-codegen
[Maven] Maven plugin can't accept additionalProperties
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When trying to pass additionalProperties without passing configOptions a NullPointerException is thrown
Swagger-codegen version
3.0.0-rc1
Swagger declaration file content or url
Not required
Command line used for generation
Not through command line but here is the XML plugin declaration:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.0-rc1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<additionalProperties>
<ngVersion>6.0.0</ngVersion>
</additionalProperties>
....
</configuration>
</execution>
</executions>
</plugin>
##### Steps to reproduce
Simply execute 'mvn generate-sources' with configuration similar to the above
Related issues/PRs
Suggest a fix/enhancement
Adapting the class CodeGenMojo by creating a method that avoids the NPE should sort out the problem:
private boolean hasConfigOption( String option ) {
return configOptions != null && configOptions.containsKey( option );
}
This method should be used in the ifs of lines: 451, 456, 461, 466, 471 and 476.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the CodeGenMojo class and inspect the conditionals at lines 451, 456, 461, 466, 471 and 476. Reproduce the issue with the shown Maven configuration using only additionalProperties, then run mvn generate-sources and verify that it completes without a NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100