Issue#5376- changes to include swagger version in generated api files (#5449)

* Elizabeth - changes to include swagger version in generated api files

* Filtering version.properties in swagger codegen module

* Removing resource filtering from swagger codegen cli module

* Merging master
This commit is contained in:
Elizabeth Thomas 2017-04-25 10:28:16 -05:00 committed by wing328
parent efb337dd92
commit 702f193f61
16 changed files with 46 additions and 17 deletions

2
.gitignore vendored
View File

@ -4,7 +4,7 @@ out/
*.iws *.iws
classpath.txt classpath.txt
version.properties version.properties
!modules/swagger-codegen-cli/src/main/resources/version.properties !modules/swagger-codegen/src/main/resources/version.properties
.project .project
.classpath .classpath
lib/* lib/*

View File

@ -18,7 +18,6 @@
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes> <excludes>
<exclude>logback.xml</exclude> <exclude>logback.xml</exclude>
</excludes> </excludes>
@ -79,17 +78,6 @@
<artifactId>swagger-codegen</artifactId> <artifactId>swagger-codegen</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!--https://github.com/airlift/airline-->
<dependency>
<groupId>io.airlift</groupId>
<artifactId>airline</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>

View File

@ -1 +0,0 @@
version = ${project.version}

View File

@ -16,6 +16,7 @@
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes> <excludes>
<exclude>logback.xml</exclude> <exclude>logback.xml</exclude>
</excludes> </excludes>
@ -249,6 +250,16 @@
<artifactId>commons-cli</artifactId> <artifactId>commons-cli</artifactId>
<version>${commons-cli-version}</version> <version>${commons-cli-version}</version>
</dependency> </dependency>
<dependency>
<groupId>io.airlift</groupId>
<artifactId>airline</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>

View File

@ -2,6 +2,7 @@ package io.swagger.codegen;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template; import com.samskivert.mustache.Template;
import io.swagger.codegen.cmd.Version;
import io.swagger.codegen.ignore.CodegenIgnoreProcessor; import io.swagger.codegen.ignore.CodegenIgnoreProcessor;
import io.swagger.models.*; import io.swagger.models.*;
import io.swagger.models.auth.OAuth2Definition; import io.swagger.models.auth.OAuth2Definition;
@ -10,6 +11,7 @@ import io.swagger.models.parameters.Parameter;
import io.swagger.util.Json; import io.swagger.util.Json;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -17,8 +19,6 @@ import org.slf4j.LoggerFactory;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import org.apache.commons.lang3.StringUtils;
public class DefaultGenerator extends AbstractGenerator implements Generator { public class DefaultGenerator extends AbstractGenerator implements Generator {
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class); protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
protected CodegenConfig config; protected CodegenConfig config;
@ -127,8 +127,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
config.processOpts(); config.processOpts();
config.preprocessSwagger(swagger); config.preprocessSwagger(swagger);
// TODO need to obtain version from a file instead of hardcoding it // TODO need to obtain version from a file instead of hardcoding it
config.additionalProperties().put("generatorVersion", "2.2.3-SNAPSHOT");
config.additionalProperties().put("generatedDate", DateTime.now().toString()); config.additionalProperties().put("generatedDate", DateTime.now().toString());
config.additionalProperties().put("generatorVersion", Version.readVersionFromResources());
config.additionalProperties().put("generatorClass", config.getClass().getName()); config.additionalProperties().put("generatorClass", config.getClass().getName());
config.additionalProperties().put("inputSpec", config.getInputSpec()); config.additionalProperties().put("inputSpec", config.getInputSpec());
if (swagger.getVendorExtensions() != null) { if (swagger.getVendorExtensions() != null) {

View File

@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package {{package}}; package {{package}};
{{#imports}}import {{import}}; {{#imports}}import {{import}};

View File

@ -0,0 +1 @@
version = ${project.version}

View File

@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package io.swagger.api; package io.swagger.api;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package io.swagger.api; package io.swagger.api;
import io.swagger.model.ModelApiResponse; import io.swagger.model.ModelApiResponse;

View File

@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package io.swagger.api; package io.swagger.api;
import java.util.Map; import java.util.Map;

View File

@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.2.3-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package io.swagger.api; package io.swagger.api;
import java.util.List; import java.util.List;