Skip to content

updated versions for release #3388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20

Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
-------------------------- | ------------ | -------------------------- | -----
2.2.0-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.2.0 | 2016-07-15 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.0](https://github.com/swagger-api/swagger-codegen/tree/v2.2.0)
2.1.6 (**current stable**) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
Expand Down
2 changes: 1 addition & 1 deletion modules/swagger-codegen-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion modules/swagger-codegen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>swagger-codegen-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/swagger-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,35 @@ public CodegenModel fromModel(String name, Model model, Map<String, Model> allDe
allRequired = null;
}
// parent model
final RefModel parent = (RefModel) composed.getParent();
RefModel parent = (RefModel) composed.getParent();

// interfaces (intermediate models)
if (composed.getInterfaces() != null) {
if (m.interfaces == null)
m.interfaces = new ArrayList<String>();
for (RefModel _interface : composed.getInterfaces()) {
Model interfaceModel = null;
if (allDefinitions != null) {
interfaceModel = allDefinitions.get(_interface.getSimpleRef());
}
// set first interface with discriminator found as parent
if (parent == null && interfaceModel instanceof ModelImpl && ((ModelImpl) interfaceModel).getDiscriminator() != null) {
parent = _interface;
} else {
final String interfaceRef = toModelName(_interface.getSimpleRef());
m.interfaces.add(interfaceRef);
addImport(m, interfaceRef);
if (allDefinitions != null) {
if (supportsInheritance) {
addProperties(allProperties, allRequired, interfaceModel, allDefinitions);
} else {
addProperties(properties, required, interfaceModel, allDefinitions);
}
}
}
}
}

if (parent != null) {
final String parentRef = parent.getSimpleRef();
m.parentSchema = parentRef;
Expand All @@ -1210,24 +1238,7 @@ public CodegenModel fromModel(String name, Model model, Map<String, Model> allDe
}
}
}
// interfaces (intermediate models)
if (composed.getInterfaces() != null) {
if (m.interfaces == null)
m.interfaces = new ArrayList<String>();
for (RefModel _interface : composed.getInterfaces()) {
final String interfaceRef = toModelName(_interface.getSimpleRef());
m.interfaces.add(interfaceRef);
addImport(m, interfaceRef);
if (allDefinitions != null) {
final Model interfaceModel = allDefinitions.get(_interface.getSimpleRef());
if (supportsInheritance) {
addProperties(allProperties, allRequired, interfaceModel, allDefinitions);
} else {
addProperties(properties, required, interfaceModel, allDefinitions);
}
}
}
}

// child model (properties owned by the model itself)
Model child = composed.getChild();
if (child != null && child instanceof RefModel && allDefinitions != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ private int getInheritanceDepth(Model model) {

private Model getParent(Model model) {
if (model instanceof ComposedModel) {
return definitions.get(((ComposedModel) model).getParent().getReference());
Model parent = ((ComposedModel) model).getParent();
if(parent != null) {
return definitions.get(parent.getReference());
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ public void processOpts() {

if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
} else if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
// guess from api package
String derviedInvokerPackage = deriveInvokerPackageName((String)additionalProperties.get(CodegenConstants.API_PACKAGE));
this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, derviedInvokerPackage);
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
LOGGER.info("Invoker Package Name, originally not set, is now dervied from api package name: " + derviedInvokerPackage);
} else if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
// guess from model package
String derviedInvokerPackage = deriveInvokerPackageName((String)additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, derviedInvokerPackage);
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
LOGGER.info("Invoker Package Name, originally not set, is now dervied from model package name: " + derviedInvokerPackage);
} else {
//not set, use default to be passed to template
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
Expand Down Expand Up @@ -845,4 +857,23 @@ public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}

/*
* Derive invoker package name based on the input
* e.g. foo.bar.model => foo.bar
*
* @param input API package/model name
* @return Derived invoker package name based on API package/model name
*/
private String deriveInvokerPackageName(String input) {
String[] parts = input.split(Pattern.quote(".")); // Split on period.

StringBuilder sb = new StringBuilder();
String delim = "";
for (String p : Arrays.copyOf(parts, parts.length-1)) {
sb.append(delim).append(p);
delim = ".";
}
return sb.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
</dependency>
</dependencies>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<jersey-version>2.22.2</jersey-version>
<jackson-version>2.7.5</jackson-version>
{{^java8}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</dependency>
</dependencies>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<retrofit-version>1.9.0</retrofit-version>
<okhttp-version>2.7.5</okhttp-version>
<jodatime-version>2.9.3</jodatime-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
</repositories>
<properties>
<maven-plugin-version>1.0.0</maven-plugin-version>
<swagger-inflector-version>1.0.4</swagger-inflector-version>
<swagger-inflector-version>1.0.8</swagger-inflector-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<logback-version>1.0.1</logback-version>
<junit-version>4.8.2</junit-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<resteasy-version>3.0.11.Final</resteasy-version>
<slf4j-version>1.6.3</slf4j-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
<akka-version>2.3.9</akka-version>
<joda-version>1.2</joda-version>
<joda-time-version>2.2</joda-time-version>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<maven-plugin.version>1.0.0</maven-plugin.version>

<junit-version>4.8.1</junit-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<gson-version>2.3.1</gson-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
<joda-version>1.2</joda-version>
<joda-time-version>2.2</joda-time-version>
<jersey-version>1.19</jersey-version>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<jersey-async-version>1.0.5</jersey-async-version>
<maven-plugin.version>1.0.0</maven-plugin.version>
<jackson-version>2.4.2</jackson-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class JavaInheritanceTest {

@SuppressWarnings("static-method")
@Test(description = "convert a composed model")
@Test(description = "convert a composed model with parent")
public void javaInheritanceTest() {
final Model model = new ComposedModel().parent(new RefModel("Base"))
.child(new ModelImpl().additionalProperties(new StringProperty()));
Expand All @@ -29,4 +33,26 @@ public void javaInheritanceTest() {
Assert.assertEquals(cm.parent, "Base");
Assert.assertEquals(cm.imports, Sets.newHashSet("Base"));
}

@SuppressWarnings("static-method")
@Test(description = "convert a composed model with discriminator")
public void javaInheritanceWithDiscriminatorTest() {
ModelImpl base = new ModelImpl();
base.setDiscriminator("disc");

final Model model = new ComposedModel()
.interfaces(Arrays.asList(new RefModel("Base")))
.child(new ModelImpl().additionalProperties(new StringProperty()));

final Map<String, Model> allDefinitions = new HashMap<String, Model>();
allDefinitions.put("Base", base);

final DefaultCodegen codegen = new JavaClientCodegen();
final CodegenModel cm = codegen.fromModel("sample", model, allDefinitions);

Assert.assertEquals(cm.name, "sample");
Assert.assertEquals(cm.classname, "Sample");
Assert.assertEquals(cm.parent, "Base");
Assert.assertEquals(cm.imports, Sets.newHashSet("Base"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void javascriptInheritanceTest() {
Assert.assertEquals(cm.vars.size(), 1);
Assert.assertEquals(cm.vars.get(0).name, "childProp");
Assert.assertEquals(cm.allVars.size(), 4);
String[] allVars = {"baseProp", "intf1Prop", "intf2Prop", "childProp"};
String[] allVars = {"intf1Prop", "intf2Prop", "baseProp", "childProp"};
for (int i = 0; i < allVars.length; i++) {
Assert.assertEquals(cm.allVars.get(i).name, allVars[i]);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public void javascriptNoInheritanceTest() {
Assert.assertEquals(cm.imports, Sets.newHashSet("Base", "Interface1", "Interface2"));
Assert.assertEquals(cm.vars.size(), 4);
Assert.assertEquals(cm.allVars.size(), 4);
String[] allVars = {"baseProp", "intf1Prop", "intf2Prop", "childProp"};
String[] allVars = {"intf1Prop", "intf2Prop", "baseProp", "childProp"};
for (int i = 0; i < allVars.length; i++) {
Assert.assertEquals(cm.vars.get(i).name, allVars[i]);
Assert.assertEquals(cm.allVars.get(i).name, allVars[i]);
Expand Down
2 changes: 1 addition & 1 deletion modules/swagger-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>swagger-generator</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<artifactId>swagger-codegen-project</artifactId>
<packaging>pom</packaging>
<name>swagger-codegen-project</name>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<url>https://github.com/swagger-api/swagger-codegen</url>
<scm>
<connection>scm:git:git@github.com:swagger-api/swagger-codegen.git</connection>
Expand Down Expand Up @@ -704,7 +704,7 @@
</repository>
</repositories>
<properties>
<swagger-parser-version>1.0.19</swagger-parser-version>
<swagger-parser-version>1.0.21</swagger-parser-version>
<scala-version>2.11.1</scala-version>
<felix-version>2.3.4</felix-version>
<swagger-core-version>1.5.9</swagger-core-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.swagger.client.ApiClient;

import io.swagger.client.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
Expand All @@ -16,6 +17,19 @@
public interface FakeApi extends ApiClient.Api {


/**
* To test \&quot;client\&quot; model
*
* @param body client model (required)
* @return Client
*/
@RequestLine("PATCH /fake")
@Headers({
"Content-type: application/json",
"Accept: application/json",
})
Client testClientModel(Client body);

/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Expand Down
Loading