Skip to content

Set supportInheritance to true for java based gens #3393

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 1 commit into from
Jul 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code

public AbstractJavaCodegen() {
super();
supportsInheritance = true;
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
apiTestTemplateFiles.put("api_test.mustache", ".java");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
public JavaCXFServerCodegen()
{
super();
supportsInheritance = true;
sourceFolder = "gen" + File.separator + "java";
outputFolder = "generated-code/JavaJaxRS-CXF";
apiTestTemplateFiles.clear(); // TODO: add test template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
public JavaJAXRSSpecServerCodegen()
{
super();
supportsInheritance = true;
sourceFolder = "src/main/java";
invokerPackage = "io.swagger.api";
artifactId = "swagger-jaxrs-server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public ApiClient(String[] authNames) {
this();
for(String authName : authNames) {
RequestInterceptor auth;
if (authName == "api_key") {
auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "petstore_auth") {
if (authName == "petstore_auth") {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if (authName == "api_key") {
auth = new ApiKeyAuth("header", "api_key");
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import io.swagger.client.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io.swagger.client.ApiClient;

import io.swagger.client.model.Pet;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
import java.io.File;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,9 @@
*/

public class Cat extends Animal {
@JsonProperty("className")
private String className = null;

@JsonProperty("color")
private String color = "red";

@JsonProperty("declawed")
private Boolean declawed = null;

public Cat className(String className) {
this.className = className;
return this;
}

/**
* Get className
* @return className
**/
@ApiModelProperty(example = "null", required = true, value = "")
public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public Cat color(String color) {
this.color = color;
return this;
}

/**
* Get color
* @return color
**/
@ApiModelProperty(example = "null", value = "")
public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public Cat declawed(Boolean declawed) {
this.declawed = declawed;
return this;
Expand Down Expand Up @@ -110,24 +68,20 @@ public boolean equals(java.lang.Object o) {
return false;
}
Cat cat = (Cat) o;
return Objects.equals(this.className, cat.className) &&
Objects.equals(this.color, cat.color) &&
Objects.equals(this.declawed, cat.declawed) &&
return Objects.equals(this.declawed, cat.declawed) &&
super.equals(o);
}

@Override
public int hashCode() {
return Objects.hash(className, color, declawed, super.hashCode());
return Objects.hash(declawed, super.hashCode());
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Cat {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" className: ").append(toIndentedString(className)).append("\n");
sb.append(" color: ").append(toIndentedString(color)).append("\n");
sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,9 @@
*/

public class Dog extends Animal {
@JsonProperty("className")
private String className = null;

@JsonProperty("color")
private String color = "red";

@JsonProperty("breed")
private String breed = null;

public Dog className(String className) {
this.className = className;
return this;
}

/**
* Get className
* @return className
**/
@ApiModelProperty(example = "null", required = true, value = "")
public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public Dog color(String color) {
this.color = color;
return this;
}

/**
* Get color
* @return color
**/
@ApiModelProperty(example = "null", value = "")
public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public Dog breed(String breed) {
this.breed = breed;
return this;
Expand Down Expand Up @@ -110,24 +68,20 @@ public boolean equals(java.lang.Object o) {
return false;
}
Dog dog = (Dog) o;
return Objects.equals(this.className, dog.className) &&
Objects.equals(this.color, dog.color) &&
Objects.equals(this.breed, dog.breed) &&
return Objects.equals(this.breed, dog.breed) &&
super.equals(o);
}

@Override
public int hashCode() {
return Objects.hash(className, color, breed, super.hashCode());
return Objects.hash(breed, super.hashCode());
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Dog {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" className: ").append(toIndentedString(className)).append("\n");
sb.append(" color: ").append(toIndentedString(color)).append("\n");
sb.append(" breed: ").append(toIndentedString(breed)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
2 changes: 0 additions & 2 deletions samples/client/petstore/java/jersey1/docs/Cat.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **String** | |
**color** | **String** | | [optional]
**declawed** | **Boolean** | | [optional]


Expand Down
2 changes: 0 additions & 2 deletions samples/client/petstore/java/jersey1/docs/Dog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **String** | |
**color** | **String** | | [optional]
**breed** | **String** | | [optional]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public ApiClient() {

// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

import io.swagger.client.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;


import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import io.swagger.client.Pair;

import io.swagger.client.model.Pet;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
import java.io.File;


import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,9 @@
*/

public class Cat extends Animal {
@JsonProperty("className")
private String className = null;

@JsonProperty("color")
private String color = "red";

@JsonProperty("declawed")
private Boolean declawed = null;

public Cat className(String className) {
this.className = className;
return this;
}

/**
* Get className
* @return className
**/
@ApiModelProperty(example = "null", required = true, value = "")
public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public Cat color(String color) {
this.color = color;
return this;
}

/**
* Get color
* @return color
**/
@ApiModelProperty(example = "null", value = "")
public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public Cat declawed(Boolean declawed) {
this.declawed = declawed;
return this;
Expand Down Expand Up @@ -110,24 +68,20 @@ public boolean equals(java.lang.Object o) {
return false;
}
Cat cat = (Cat) o;
return Objects.equals(this.className, cat.className) &&
Objects.equals(this.color, cat.color) &&
Objects.equals(this.declawed, cat.declawed) &&
return Objects.equals(this.declawed, cat.declawed) &&
super.equals(o);
}

@Override
public int hashCode() {
return Objects.hash(className, color, declawed, super.hashCode());
return Objects.hash(declawed, super.hashCode());
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Cat {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" className: ").append(toIndentedString(className)).append("\n");
sb.append(" color: ").append(toIndentedString(color)).append("\n");
sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
Loading