kongchen/swagger-maven-plugin

-Dswagger.skip=false doesn't trigger plugin

lorencole opened this issue · 1 comments

We'd like to only build our API spec in specific cases and have the plugin skipped by default. So in pom.xml we've got:

<plugin>
				<groupId>com.github.kongchen</groupId>
				<artifactId>swagger-maven-plugin</artifactId>
				<version>3.1.8</version>
				<configuration>
					<skipSwaggerGeneration>true</skipSwaggerGeneration>
					<apiSources> ...

This skips spec generation by default, but $ mvn compile -Dswagger.skip=false also skips generation. Using 3.1.8.

Hi @lorencole, that's because the default value of <skipSwaggerGeneration> is:

<skipSwaggerGeneration>${swagger.skip}</skipSwaggerGeneration>

By using <skipSwaggerGeneration>true</skipSwaggerGeneration>, you "hardcode" true and remove the usage of of the swagger.skip property. To solve your problem, remove <skipSwaggerGeneration> and add the following to your pom.xml:

<properties>
  <!-- (...) -->
  <swagger.skip>true</swagger.skip>
</properties>

This way the swagger.skip property will default to true, but you can override it to false by specifying the system property via -Dswagger.skip=false.